C# || NLogN || Binary search || DP
\n    public int MaxEnvelopes(int[][] envelopes)\n    {\n        Array.Sort(envelopes, (a, b) => a[0] == b[0] ? b[1].CompareTo(a[1]) : a[0].CompareTo(b[0]));\n\
```\n    public int MaxEnvelopes(int[][] envelopes)\n    {\n        Array.Sort(envelopes, (a, b) => a[0] == b[0] ? b[1].CompareTo(a[1]) : a[0].CompareTo(b[0]));\n\n        int[] dp = new int[envelopes.Length];\n        int len = 0;\n        foreach(int[] envelope in envelopes){\n            int index = Array.BinarySearch(dp, 0, len, envelope[1]);\n            if(index< 0)\n                index = ~index;\n            dp[index] = envelope[1];\n            if(index == len)\n                len++;\n        }\n        return len;\n    }\n```
['Binary Search', 'Dynamic Programming']