Here is the link for my code
I used the this implementation of segment tree to solve this question link text
I tried some test cases and getting expected answer.
But when I submit my code not a single test case passes. Please help me to point out the mistake in my code.
Thanks in advance.