Check all substrings. For each substring, scan to verify all characters are unique.
There are substrings. Checking each for uniqueness takes . Total: .
For , that's about operations. Far too slow.
The trap
Check all substrings. For each substring, scan to verify all characters are unique.
There are substrings. Checking each for uniqueness takes . Total: .
For , that's about operations. Far too slow.