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 (a,b) if and only if b is less than c. Chains of pairs can be formed in this manner. Find the longest chain of pairs formed.

I got this question in an interview with Amazon but couldn't figure out the answer, just that it is related to the LIS problem.

Edit
Report