Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Nghĩa Huỳnh Trung
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