Simple C# Solution
\n    public class Solution\n    {\n        public int MaxEnvelopes(int[][] envelopes)\n        {\n            if (envelopes.Length == 0)\n            {\n      
```\n    public class Solution\n    {\n        public int MaxEnvelopes(int[][] envelopes)\n        {\n            if (envelopes.Length == 0)\n            {\n                return 0;\n            }\n\n            if (envelopes.Length == 1)\n            {\n                return 1;\n            }\n\n            Array.Sort(envelopes, (e1, e2) =>\n            {\n                var wCmp = e1[0].CompareTo(e2[0]);\n                if (wCmp != 0)\n                {\n                    return wCmp;\n                }\n\n                return e1[1].CompareTo(e2[1]);\n            });\n\n            int[] dp = new int[envelopes.Length];\n\n            dp[0] = 1;\n\n            for (int i = 1; i < envelopes.Length; i++)\n            {\n                dp[i] = 1;\n                var curr = envelopes[i];\n\n                for (int j = 0; j < i; j++)\n                {\n                    var prevDp = dp[j];\n                    var prev = envelopes[j];\n\n                    if (prev[0] < curr[0] && prev[1] < curr[1])\n                    {\n                        if (prevDp + 1 > dp[i])\n                        {\n                            dp[i] = prevDp + 1;\n                        }\n                    }\n                }\n            }\n\n            return dp.Max();\n        }\n    }\n```
['Dynamic Programming']