Tirth and Badminton Hackerearth problem

Can someone provide the editorial of this hackerearth problem? Specially @meooow can you please look at this question?

Hint 1: ‘and’ will keep on decreasing if we fix right end point of sub-array and keep on decreasing left end point.

Hint 2: Binary search.

Actually I did solve this problem after seeing your question, but with a hacky \mathcal{O}(n^2) optimized solution which I cannot be sure is fast enough for some worst case. I took a look at the editorial just now which uses a very convoluted way involving bits and a segment tree. @adkroxx’s approach is likely better than both of these, so @adkroxx if you could explain further that will be helpful :slight_smile:

1 Like

Can you please explain in detail?

//