1794. Count Pairs of Equal Substrings With Minimum Difference
https://leetcode.com/problems/count-pairs-of-equal-substrings-with-minimum-difference
Description
You are given two strings firstString and secondString that are 0-indexed and consist only of lowercase English letters. Count the number of index quadruples (i,j,a,b) that satisfy the following conditions:
0 <= i <= j < firstString.length0 <= a <= b < secondString.lengthThe substring of
firstStringthat starts at theithcharacter and ends at thejthcharacter (inclusive) is equal to the substring ofsecondStringthat starts at theathcharacter and ends at thebthcharacter (inclusive).j - ais the minimum possible value among all quadruples that satisfy the previous conditions.
Return the number of such quadruples.
Example 1:
**Input:** firstString = "abcd", secondString = "bccda"
**Output:** 1
**Explanation:** The quadruple (0,0,4,4) is the only one that satisfies all the conditions and minimizes j - a.Example 2:
**Input:** firstString = "ab", secondString = "cd"
**Output:** 0
**Explanation:** There are no quadruples satisfying all the conditions.Constraints:
1 <= firstString.length, secondString.length <= 2 * 105Both strings consist only of lowercase English letters.
ac
Last updated
Was this helpful?