# LC5487 Maximum Length of Pair Chain **Approach.** Sort by right end; greedy like activity selection. ```python def findLongestChain(p): cur, n = float('-inf'), 0 for a, b in sorted(p, key=lambda x: x[1]): if a > cur: cur = b; n += 1 return n ``` **Interview tip.** Name the pattern first, then the invariant, then code. To rehearse explaining solutions under pressure, try [AI coding interview assistant](https://www.linkjob.ai/) — https://www.linkjob.ai/ .