Back to course home
0% completed
Vote For New Content
Simple solution using GO + array stack
Nghĩa Huỳnh Trung
Jun 25, 2025
func (this *Solution) removeDuplicates(str string, k int) string { stack := []rune{} for _, rune := range str { count := 0 for len(stack) > count && rune == stack[len(stack)-count-1] { count++ } if count == k-1 { stack = stack[:len(stack)-k+1] continue } stack = append(stack, rune) } return string(stack) }
0
0
Comments
Comments