-
I am a beginner and hope to get your help
-
it is remove-duplicates-from-sorted-array
func remove(nums []int)int{ i,j:= 0,0 //Why is it wrong to use if here? // if j< len(nums) for j < len(nums){ if i==0 || nums[i-1]!= nums[j]{ nums[i] = nums[j] i++ j++ }else{ j++ } } return i}
func main(){ nums := []int{1,2,2,3,5,5} result := remove(nums) fmt.Println(result) } -
please help me
samedi 13 novembre 2021
Why is it wrong to use if here,in golang,remove-duplicates-from-sorted-array
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire