Idk that this is an actual good Go solution - I'm not a Go expert so it can be hard for me to tell sometimes. It's so idiomatically verbose!
func Count(a []int) (r []int) { r = make([]int, 0) if len(a) == 0 { return } var pos int = 0 var neg int = 0 for _, item := range a { if item >= 0 { pos += 1 } else { neg += item } } r = append(r, pos) return append(r, neg) }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Idk that this is an actual good Go solution - I'm not a Go expert so it can be hard for me to tell sometimes. It's so idiomatically verbose!