Here in this blog… which is hackwithinfy previous year question paper… In question number -2(MAX GAPPING) …i can think about n^2 approch …But here they are asking to come up with nlogn… Can you recommend any logic or steps…
The link of blog is-- https://akashwho.codes/blog/hackwithinfy-round-2-experience-with-questions/
Not able to get optimal solution
This is a modification to this LIS problem, Instead of increasing the terms are just decreasing
read more about it at https://www.geeksforgeeks.org/longest-monotonically-increasing-subsequence-size-n-log-n/