Created
April 18, 2020 15:27
-
-
Save mtpereira/0923b402ef96de17c0811e453e46fc43 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package ch4 | |
import ( | |
"fmt" | |
) | |
func removeAdjacentDuplicates(s []string) { | |
previous := 0 | |
for i := 1; i < len(s); i++ { | |
if s[i] == s[previous] { | |
s[i] = "" | |
previous = i | |
} | |
} | |
copy(s, s[:previous]) | |
fmt.Println(s, len(s), cap(s)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment