Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Brute force is a good choice because length of the string is ≤ 1000.
Binary search the answer.
Use Trie data structure to store the best three matching. Traverse the Trie.