354. Russian Doll Envelopes

idea - sort w by asc first, but when w are the same, h do sort by desc, the focus on h find the LIS (leetcode 300)
when widths are the same, why height should do sort by desc?

簡而言之 就是為了對 h 做 LIS 找到最後的答案, 所以 w 一樣時, h 要做 desc 不然因為 LIS 是 asc 的 => 會錯
sort + DP + binary search
O(n^2) TLE
Previous300. Longest Increasing Subsequence (LIS)Next1964. Find the Longest Valid Obstacle Course at Each Position
Last updated
Was this helpful?