Search
⌘K

Leetcode 1156. Swap For Longest Repeated Character Substring

Given a lowercase string where you may swap any two characters once, find the maximum length of a substring consisting of the same character after at most one swap. Think in terms of run-length groups and character counts: you can extend a run with extra occurrences elsewhere or merge two same-character runs separated by a single different char when a spare character exists.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.