Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void removeDuplicate(String& str){
- if(str.length < 2) {
- return;
- }
- int f = 1, s = 0;
- while(f < str.length) {
- if (str[s] != str[f]) {
- str[++s] = str[f++];
- } else {
- f++;
- }
- }
- str.resize(s + 1);
- }
Advertisement
Add Comment
Please, Sign In to add comment