SUBPRNJL - EDITORIAL

Can anyone please help me with the solution of the last problem of the STL question in DSA learning series. Why one of my test case is giving TLE? Please help !!

Link to the question

Link to my solution