Longest increasing Subsequence || O(Nlogn) || Easy CPP Code
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    static bool comp(pair<int,int> &a,pair<int,int>&b){\n        if(a.first==b.first){\n            return a.second>b.second;\n        }\n        else{\n            return a.first<b.first;\n        }\n    }\n\n    int maxEnvelopes(vector<vector<int>>& env) {\n        vector<pair<int,int>>arr(env.size());\n        for(int i = 0 ; i < env.size() ; i++){\n            arr[i] = {env[i][0],env[i][1]};\n        }\n\n        sort(arr.begin(),arr.end(),comp);\n        \n        vector<int>dp(env.size());\n        int ans = 0;\n\n        for(int i = 0 ; i < env.size() ; i++)\n        {\n            int l = 0;\n            int h = ans;\n            while(l<h){\n                int m = l +(h-l)/2;\n\n                if(dp[m] < arr[i].second) l = m + 1;\n                else h = m;\n            }\n\n            dp[l] = arr[i].second;\n            if(l == ans) ans++;\n        }\n        return ans;\n    }\n};\n```
['Binary Search', 'Dynamic Programming', 'Sorting', 'C++']