Handle Score
@Ibrahim Nash 5725
@blackshadows 5685
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4908
@saiujwal13083 4156
@sanjay05 3762
@marius_valentin_dragoi 3511
@sushant_a 3453
@KshamaGupta 3318
@the_coder95 3302
Complete Leaderboard
Remove Duplicates
Easy Accuracy: 60.92% Submissions: 2785 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 = "geeksforGeeks"
Output: geksfor
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

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