marblegef DOUBT..

i did this problem using segmented tree concept…but i am getting tle…editorial say to use fenwick tree concept…But i came to know both fenwick tree and segmented tree have same time complexity in worst case which is O(mlogn)…anyone clear my doubt plsss…thanks in advance:)

this is my code which uses the concept of segment tree

I read somewhere that the constant factor in complexity calculation of segment tree is more than BIT. So for extremely steep time limit, BIT is effective.

1 Like