Array101 Remove Duplicates from Sorted Array
My code func removeDuplicates(nums []int) int { if nums == nil { return 0 } k := 0 for _, v := range nums { if v != nums[k] { k++ nums[k] = v } } return k + 1 } I used for loop value output. It starts from array[0]. So if it will be different with value, k will be increased and value will be input there. Simple Code. sample 0 ms submission func removeDuplicates(nums []int) int { if len(nums) < 2..
Go/Leet Code
2022. 3. 6. 22:00