envelopes array. First by width in ascending order, and then by height in descending order for envelopes with the same width.dp to store the ends of the increasing subsequences.envelopes, and for each envelope:
a. Use binary search to find the index i in dp where the current envelope's height can be placed (or replace an existing one).
b. If i is equal to the length of dp, append the height to dp.
c. Otherwise, replace dp[i] with the current envelope's height.dp is the maximum number of envelopes that can be Russian dolled.