text of lowercase English letters. Call a non-empty block of consecutive characters **sealed** if it is not the whole string and every letter that appears in it appears nowhere else in text outside the block.
Return the length of the longest sealed block, or -1 if there is none.text="xyyxzz" → 4
The block "xyyx" holds every x and y of the string and no z. The whole string does not count, and "xyyxz" fails because one z is left outside.
text="mnmn" → -1
Any block shorter than the whole string takes an m or an n but not all of its copies.
text="pqrp" → 2
The blocks "q", "r" and "qr" all work, and "qr" is the longest. A block with a p has to take both p's, which means the whole string.
text consists of lowercase English letterstext="xyyxzz"
4
Run checks the first 3 tests in your browser. Submit checks all 90 tests on the server, hidden ones included.