1)sir on printing the treeseg.size() it is printing 21 for the test case below (in line 93 of the code);
2) sir i think there is some problem with the query function.
https://ide.codingblocks.com/s/199476 is my code id
5
1 2 3 4 5
5
1 4 1
1 5 2
1 5 3
1 5 4
1 5 5
is the required test case