C++ || LIS Pattern || Easy Implementation || Binary Search
\nclass Solution {\npublic:\n    int LIS(vector<int>&nums){\n        if(nums.size() == 0) return 0;\n        vector<int> ans;\n        ans.push_back(nums[0]);\n
```\nclass Solution {\npublic:\n    int LIS(vector<int>&nums){\n        if(nums.size() == 0) return 0;\n        vector<int> ans;\n        ans.push_back(nums[0]);\n        for(int i=1;i<nums.size();i++){\n            if(nums[i] >= ans.back()){\n                ans.push_back(nums[i]);\n            }\n            else{\n                int idx = upper_bound(ans.begin(),ans.end(),nums[i]) - ans.begin();\n                ans[idx] = nums[i];\n            }\n        }\n        return ans.size();\n    }\n    int kIncreasing(vector<int>& arr, int k) {\n        int cnt = 0;\n        for(int i=0;i<k;i++){\n            vector<int> curr;\n            for(int j=i;j<arr.size();j+=k){\n                curr.push_back(arr[j]);\n            }\n            cnt += (curr.size() - LIS(curr));\n        }\n        return cnt;\n    }\n};\n```\n**Guys don\'t forget to upvote me!**
['Binary Search', 'C']