LIS | run time : O(n logn) | space : O(n)
\nclass Solution {\n    public int maxEnvelopes(int[][] envelopes) {\n        Arrays.sort(envelopes, (a, b) -> a[0] != b[0] ? a[0] - b[0] : b[1] - a[1]);\n     
```\nclass Solution {\n    public int maxEnvelopes(int[][] envelopes) {\n        Arrays.sort(envelopes, (a, b) -> a[0] != b[0] ? a[0] - b[0] : b[1] - a[1]);\n        List<Integer> result = new ArrayList<>();\n        result.add(envelopes[0][1]);\n        for (int i = 1; i < envelopes.length; ++i) {\n            if (result.get(result.size() - 1) < envelopes[i][1])\n                result.add(envelopes[i][1]);\n            else {\n                int idx = Collections.binarySearch(result, envelopes[i][1]);\n                result.set(idx < 0 ? -idx - 1 : idx, envelopes[i][1]);\n            }\n        }\n        return result.size();\n    }\n}\n```
['Dynamic Programming', 'Binary Tree', 'Java']