I am using O(n logn) solution but still I’m getting TLE, is there any other way to modify the code or if someone can suggest a more efficient approach. Any other approach other than offline fenwick trees!
MAX Query-1 getting TLE
declare array or vector globally and try again. or use segment tree with each node as a policy based data structute. Complexity will be O(n (log(n)^2)) but it will work. make sure you declare everything globally.
Thanks sir, I got AC.
But still I wanna know what is the complexity of my code which I used initially.Was it not O(qlogn) becz what I know is query can be performed in log(n) time and we are in total performing Q queries than why my code is not working
suppose k is greater than every element in the segment tree. than ? think
if (qlow <= low && high <= qhigh) { if (seg[node] >= k) return (high - low + 1); }
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
Can you please expain it a little more?
I am also getting tle for the same logic.