first and second (their lengths may differ). For every letter from a to z, count how many times it occurs in each string.
Return True if, for every letter, the two counts differ by at most 3, and False if any letter has a gap of 4 or more.first="bananas", second="cabbage" → True
a: 3 vs 2, n: 2 vs 0, s: 1 vs 0, b: 1 vs 2, c, g, e: 0 vs 1, so no gap exceeds 3.
first="zzzzk", second="kkkkk" → False
z appears 4 times in the first string and never in the second.
first="bananas", second="cabbage"
True
Run checks the first 3 tests in your browser. Submit checks all 146 tests on the server, hidden ones included.