Given a string str that may contain both lowercase and uppercase letters, your task is to remove all duplicate characters from str while preserving the order of their first occurrence.
Input: "HappyProgramming"
Output: "HapyProgrmin"
Explanation: The resultant string is formed by retaining the first occurrence of each character.
Input: "aAaAaA"
Output: "aA"
Explanation: The first occurrence of a and A is preserved, and the duplicates are removed.
Approach, complexity and clean code in every language. Sign in to unlock the editorial.
Your submissions, results and runtime history live here. Sign in to start your streak.
HappyProgramming
HapyProgmin
aAaAaA
aA
HaPpyNewYear
HaPpyNewYr