Google | Phone screen | Remove Duplicate Letters from a string

Remove Duplicate Letters from a string

Given a string, remove letters having a pair of lowercase letter followed by same uppercase letter and vice-versa from a string and return that string.

Example 1:

Input: abcCkDdppGGa
Output: abkppGGa
Explanation:
cC is one such pair where same lowercase and uppercase letters are repeated.
Dd is one such pair where same uppercase and lowercase letters are repeated.

Example 2:
Input: jHYti
Output: jHYti
Explanation:
There are no pairs where same lowercase and uppercase letters repeated adjacently.

Comments (9)