digits made of decimal digits. Call a substring **even** if every digit that occurs in it occurs the same number of times. For example, "1221" and "507" are even, while "1121" is not.
Return the number of **distinct** even substrings of digits. Equal substrings found at different positions are counted once.digits='3443' → 6
The pieces that work are "3", "4", "34", "44" (a single digit twice is fine), "43" and "3443" (two 3s and two 4s). "344" and "443" do not. That makes 6.
digits='777' → 3
Every substring is all 7s, but only three are distinct: "7", "77" and "777".
digits='120' → 6
digits.length ≤ 2000digits consists of the digits 0–9 onlydigits='3443'
6
Run checks the first 3 tests in your browser. Submit checks all 128 tests on the server, hidden ones included.