Problem
My Solution
I don’t know why it is giving TLE.
Use const reference of the sg vector in the range function.
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
nice