Description
Given two strings s and t, return the count of non-empty substrings of s and t that differ by exactly one character.
Examples
Input:
s = "aba", t = "baba"Output:
6Explanation:
6 valid pairs.
Input:
s = "a", t = "a"Output:
0Explanation:
Edge case with a single character.
Input:
s = "abc", t = "def"Output:
9Explanation:
Since no characters match between s and t, every possible substring pair of the same length will differ by exactly one character. The valid pairs are: (a,d), (b,e), (c,f), (ab,de), (bc,ef), (ac,de), (ab,ef), (abc,def), totaling 9 pairs where each differs by exactly one character.
Constraints
- •
1 ≤ s.length, t.length ≤ 100