WA in finding Longest Increasing subsequence in nlogn time complexity

I am practising a problem in hackerearth called Inversion Graphs.

I have solved using Longest Increasing subsequence in O(nlogn) algorithm.
My solution has passed all the test cases except the one test case #7.

Surprisingly, my solution is similar to the editorial one.

Link to the code : Online Compiler and IDE - GeeksforGeeks

If the above link does not work, try this : Inversion Graphs - Pastebin.com

Thank you in advance :slight_smile:

https://cp-algorithms.com/sequences/longest_increasing_subsequence.html
Go through this

I have implemented the same thing right? Any wrong in my code?