Remove Duplicates
Level EASY
Given a string S, remove consecutive duplicates from it recursively.
Input Format :
Output Format :
Constraints :
Sample Input 1 :
Sample Output 1 :
Sample Input 2 :
Sample Output 2 :
xyzwz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s= [x for x in input()] | |
n=len(s) | |
j=0 | |
res="" | |
for i in range(1,n): | |
if s[i] == s[j]: | |
s[j] = " " | |
j=j+1 | |
else: | |
j=j+1 | |
print(res.join(s).replace(" ","")) |
Comments
Post a Comment
Please give us your valuable feedback