cCdDd is paired, while cCd is not, because it has no uppercase D.
Given a string text of English letters, find its longest contiguous piece that is a paired string and return it. If several pieces share the maximum length, return the one that starts first. If there is no paired piece at all, return an empty string.text="xKkqQkz" → 'KkqQk'
In KkqQk the letter k appears as both K and k, and q as both q and Q. Neither x nor z can be added, since their other case is missing.
text="aAxbB" → 'aA'
Both aA and bB qualify with length 2, so the one that starts earlier is returned.
text="Mn" → ''
No letter has its pair, so the answer is the empty string.
text consists of lowercase and uppercase English letterstext="xKkqQkz"
'KkqQk'
Run checks the first 3 tests in your browser. Submit checks all 125 tests on the server, hidden ones included.