Let ALPHABET_SIZE be the number of distinct alphabets in the string. Clearly, ALPHABET_SIZE <= 52 (if only upper and lower cases allowed). Now, we have to answer yes or no only. So for each pair of characters we have to check if we can form two non overlapping sequences of length 2 each. We maintain indices of each character and try to greedily construct the sub sequences. The complexity is **O(N * ALPHABET_SIZE ^ 2)**

# Greedy solution

**Sparsh5008**#1