Binary Search+Checker in O(n^2)

I made a solution using binary search for today’s contest’s good segment one on the number of elements with a checker in O(n^2) and I am over it thinking now, but couldn’t optimize it… Is this approach even feasible or I should drop it and start fresh??
Thanks in advance!
O(n^2*(log(n)) solution

I did this but it got TLE. I even tried with Binary search+ Segment Tree, but it did not work out. I think the binary lifting approach is the only one feasible.

1 Like