The problem. Given a string s made only of the characters 0, 1 and 2, count the substrings that contain equally many 0s, 1s and 2s.
s = "0102010" -> 2 ("102" and "201")
s = "102100211" -> 5
s = "0011" -> 0 (no 2s at all)Free account
Sign up to read the rest of this lesson: 7 more sections, 2 drawings, a dry-run simulator and code in JavaScript, Python, Java and C++.
Still to come