TREESET || JAVA
\n   \n    class Solution {\n\tpublic int maxEnvelopes(int[][] envelopes) {\n\t\n        //sorting the array width wise but when equal sorting in descending ord
\n   \n    class Solution {\n\tpublic int maxEnvelopes(int[][] envelopes) {\n\t\n        //sorting the array width wise but when equal sorting in descending order of the heights\n        Arrays.sort(envelopes,(a,b)-> a[0]!=b[0] ? a[0]-b[0] : b[1]-a[1]);\n        \n        //implementing treeset which implements bst interface\n        TreeSet<Integer> s=new TreeSet<>();\n        \n        //code for finding LIS of the height values in O(nlogn) time\n        for(int i=0;i<envelopes.length;i++){\n            Integer higher_value=s.ceiling(envelopes[i][1]);\n            \n            if(higher_value==null){\n                s.add(envelopes[i][1]);\n            }\n            \n            else{\n                s.remove(higher_value);\n                s.add(envelopes[i][1]);\n            }\n            \n        }\n        return s.size();\n    }\n}
[]