digits made of the digits 0 to 4, and an integer min_len.
Pick a substring (a contiguous piece) of length at least min_len and two different digits a and b such that, inside that substring:
- digit a occurs an **odd** number of times;
- digit b occurs an **even** number of times, and at least twice (so it is actually present).
Other digits may occur in the substring any number of times.
Return the largest possible value of count(a) - count(b) over all such choices. The answer may be negative.digits="3011", min_len=3 → -1
In the substring "011", digit 0 occurs once (odd) and 1 twice (even): 1 - 2 = -1. Nothing does better.
digits="2224400", min_len=5 → 1
Take "22244": 2 occurs 3 times and 4 twice, so the difference is 3 - 2 = 1.
digits="1113300", min_len=3 → 1
digits contains only the digits 0–4digits="3011", min_len=3
-1
Run checks the first 3 tests in your browser. Submit checks all 108 tests on the server, hidden ones included.