RTE in test cases (Java)

Hi, I’ve created a lazy propagation segmentation tree but getting RTE in all test cases. Could you please help?

Or you can tell me one of the test cases where it fails and I can debug it.

@Anshul-Chauhan-10221922864290257
In line 73 and 74
If you are at leaf and try to go to their children you may go beyond size of array
So check if 2*indx and 2*index+1 is less than max size

Thanks @Aarnav-Jindal-1059677350830863
I’ve fixed the RTE but now I’m getting TLE in all the test cases. Could you please help.

@Anshul-Chauhan-10221922864290257
Try to precalculate the power modulo values upto max value