(Help needed) Give those children some marks!

My Solution
I don’t know why it is giving TLE.


Use const reference of the sg vector in the range function.

How will it affect my code?

In range function, pass sg by reference. Else it would create duplicate of sg array everytime you call it, making it O(n).

1 Like

Solved it using array.

Thanks for explanation