MAX QUERY problem


Why this code is giving TLE ?

You need to use segment tree with vectors for this problem or process the queries offline. It’s similar to SPOJ KQUERY.

Yeah that I got to know from the hint but I was asking what’s the mistake in my code

The problem is your code won’t run efficiently for answering queries. That’s why above approaches are recommended.

okay thanks for the information!