...
https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/description/
Status | ||||
---|---|---|---|---|
|
Code Block | ||
---|---|---|
| ||
func removeDuplicates(nums []int) int { slow, fast := 0, 0 for fast < len(nums) { // fmt.Printf("slow = %d, fast = %d | %v | %v\n", // slow, fast, nums[:slow], nums, // ) if slow-2 < 0 || nums[fast] != nums[slow-1] || nums[fast] != nums[slow-2] { // new element nums[slow] = nums[fast] slow++ } fast++ } return slow } |
...