SegTree Approach