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