Remove Duplicates
Easy Accuracy: 55.08% Submissions: 26000 Points: 2

Given a string without spaces, the task is to remove duplicates from it.

Note: The original order of characters must be kept the same. 

Example 1:

Input: S = "zvvo"
Output: "zvo"
Explanation: Only keep the first

Example 2:

Input: S = "gfg"
Output: gf
Explanation: Only keep the first

Your task:
Your task is to complete the function removeDups() which takes a single string as input and returns the string. You need not take any input or print anything.

Expected Time Complexity: O(|s|)
Expected Auxiliary Space: O(constant)

1 <= |S| <= 105
S conatins lowercase english alphabets

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Remove Duplicates

Output Window