I am getting wrong answer in PRMQ

Here is the link for my code
link text

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.

Your program prints wrong result for this-

Input
5
36 180 7200 5 20
2
2 5 1 7200
1 5 1 6
Your Output
17
18
Expected Output
18
22

Usually when numbers are small combination of primes (Eg- 2^x, or 2^x * 3), your code prints correct result. If i would find such a deviation, then i would most probably check the combining of nodes and query function. (Sorry, not too familiar with java, so cant help much with exact implementations)

2 Likes

Found my mistake…I forgot a ‘=’ sign in line 78 in this piece of code " j*j<element"

Thank you for your reply.

1 Like