maybesomeone's blog

By maybesomeone, history, 2 years ago, In English

let array A = {1,3,1,1,1,4,0,0,2,3,1,}

We have to do following 2 operations on it

1.)Decrease all elements from L to R by 1

2.)Given i find right most element j such that for each k. i <= k <= j. A[k] > 0

how can i do this in log(N) ?

  • Vote: I like it
  • +5
  • Vote: I do not like it

| Write comment?
»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

yeah use binary search

»
2 years ago, # |
  Vote: I like it -8 Vote: I do not like it

Stop learning useless algorithms, go and solve some problems, learn how to use binary search — by (You know this :p)

  • »
    »
    2 years ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    i didn't asked for suggestion. go and solve Watermelon problem :p