Skip to content

Instantly share code, notes, and snippets.

@mtpereira
Created April 18, 2020 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtpereira/0923b402ef96de17c0811e453e46fc43 to your computer and use it in GitHub Desktop.
Save mtpereira/0923b402ef96de17c0811e453e46fc43 to your computer and use it in GitHub Desktop.
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