Java NLogN Solution with Explanation
Sort the array. Ascend on width and descend on height if width are same.\n 2. Find the [longest increasing subsequence][1] based on height. \n\n\n----------\n\n
 1. Sort the array. Ascend on width and descend on height if width are same.\n 2. Find the [longest increasing subsequence][1] based on height. \n\n\n----------\n\n - Since the width is increasing, we only need to consider height. \n - [3, 4] cannot contains [3, 3], so we need to put [3, 4] before [3, 3] when sorting otherwise it will be counted as an increasing number if the order is [3, 3], [3, 4]\n\n\n----------\n\n\n    public int maxEnvelopes(int[][] envelopes) {\n        if(envelopes == null || envelopes.length == 0 \n           || envelopes[0] == null || envelopes[0].length != 2)\n            return 0;\n        Arrays.sort(envelopes, new Comparator<int[]>(){\n            public int compare(int[] arr1, int[] arr2){\n                if(arr1[0] == arr2[0])\n                    return arr2[1] - arr1[1];\n                else\n                    return arr1[0] - arr2[0];\n           } \n        });\n        int dp[] = new int[envelopes.length];\n        int len = 0;\n        for(int[] envelope : envelopes){\n            int index = Arrays.binarySearch(dp, 0, len, envelope[1]);\n            if(index < 0)\n                index = -(index + 1);\n            dp[index] = envelope[1];\n            if(index == len)\n                len++;\n        }\n        return len;\n    }\n\n\n  [1]: https://leetcode.com/problems/longest-increasing-subsequence/
['Dynamic Programming', 'Java']