Guest User

Untitled

a guest
May 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. package solution
  2.  
  3. // you can also use imports, for example:
  4. // import "fmt"
  5. // import "os"
  6.  
  7. // you can write to stdout for debugging purposes, e.g.
  8. // fmt.Println("this is a debug message")
  9.  
  10. func Solution(N int, A []int) []int {
  11. max := 0
  12. counters := make([]int,N+1)
  13. for _,val := range A{
  14. if val == N + 1{
  15. for i:=1;i<=N;i++{
  16. counters[i] = max
  17. }
  18. continue
  19. }
  20. counters[val] += 1
  21. if counters[val] > max {
  22. max = counters[val]
  23. }
  24.  
  25. }
  26. return counters[1:]
  27. }
Add Comment
Please, Sign In to add comment