Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package solution
- // you can also use imports, for example:
- // import "fmt"
- // import "os"
- // you can write to stdout for debugging purposes, e.g.
- // fmt.Println("this is a debug message")
- func Solution(N int, A []int) []int {
- max := 0
- counters := make([]int,N+1)
- for _,val := range A{
- if val == N + 1{
- for i:=1;i<=N;i++{
- counters[i] = max
- }
- continue
- }
- counters[val] += 1
- if counters[val] > max {
- max = counters[val]
- }
- }
- return counters[1:]
- }
Add Comment
Please, Sign In to add comment