Last active
December 19, 2015 06:59
-
-
Save rfaisal/5915880 to your computer and use it in GitHub Desktop.
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
public class RemoveDuplicates | |
{ | |
public string removeDuplicates(string input) | |
{ | |
StringBuilder sb = new StringBuilder(input); | |
int index=0; | |
for (int i = 1; i<sb.Length; i++) | |
{ | |
if(sb[index]!=sb[i]){ | |
index++; | |
sb[index]=sb[i]; | |
} | |
} | |
sb.Length=index+1; | |
return sb.ToString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment