text.
The original word is unknown. Return the smallest length it could have had.
The word may be the whole string: a single unshuffled copy is a valid option too.text="xyyxyxxy" → 2
Blocks of length 2 are "xy", "yx", "yx", "xy", all rearrangements of "xy". Length 1 fails because the letters differ.
text="ppppqq" → 6
With length 2 the blocks "pp", "pp", "qq" differ in letters, and with length 3 so do "ppp" and "pqq". Only the whole string remains: 6.
text="abcab" → 5
The length 5 is prime, so the word is the whole string.
text consists of lowercase English letterstext="xyyxyxxy"
2
Run checks the first 3 tests in your browser. Submit checks all 76 tests on the server, hidden ones included.