I implemented my solution using LIS(nlogn way) in this Problem F: LIS on Tree. Issue is I'm Facing that,by changing the position changing the snippet code where LIS is getting calculated is giving me correct answer but giving TLE(time limit exceeded) in other way. As far as i can see this does not change the time complexity any how. Am I missing something conceptually on knowledge of LIS or on DFS?
TLE When LIS calculation inside for loop
Accepted after changing LIS snippet outside for loop
In your first code the problem is in this line —
set<int> temp=seq;
because it copy original set to the new set with time complexity O(n). This is the reason why you first code is giving verdictTLE
.