You are given
n
pairs of numbers. In every pair, the first number is always smaller than the second number. A pair(c,d)
can follow
We can start with Brian's approach, of sorting all the pairs based on y value. It will ensure the required condition of prev pair's X < next pair's y. Now all we need is longest increasing subsequence of x among the new list of pairs. Which we can get by sorting all x and finding longest common subsequence between sorted x and new list previously created