Given envelopes with width and height, determine the maximum number of envelopes you can nest one inside another. A custom sort by width ascending and height descending is required before applying a longest increasing subsequence step.
envelopes = array of [width, height]
maximum number of nested envelopes
Example 1:
Input:
envelopes = [[5,4],[6,4],[6,7],[2,3]]
Output:
3
Explanation:
One optimal chain is [2,3] -> [5,4] -> [6,7].
Example 2:
Input:
envelopes = [[1,1],[1,1],[1,1]]
Output:
1
Explanation:
Equal envelopes cannot nest inside each other.