Skip to content

Instantly share code, notes, and snippets.

@rfaisal
Last active December 19, 2015 06:59
Show Gist options
  • Save rfaisal/5915880 to your computer and use it in GitHub Desktop.
Save rfaisal/5915880 to your computer and use it in GitHub Desktop.
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