Problem 1234 · Medium

Replace the Substring for Balanced String

Find the shortest substring that, when replaced, leaves four letter types equally frequent in a string. The visual shows the excess count of each letter and a sliding window that shrinks while the balance holds.

Open the interactive visualisation