C++ | Binary Search | LIS
\nclass Solution {\n    int getPos(int val, vector<int>&v) {\n        int high = v.size()-1, low = 0; \n        int idx{}; \n        while (low < high) {\n     
```\nclass Solution {\n    int getPos(int val, vector<int>&v) {\n        int high = v.size()-1, low = 0; \n        int idx{}; \n        while (low < high) {\n            int mid = (low + high) / 2; \n            if (val >= v[mid]) {\n                low = mid + 1; \n            } else {\n                high = mid; \n            }\n        }\n        return low;\n    }\n    int process(vector<int>&v) {\n        vector<int>lis; \n        int n = 0; \n        lis.push_back(v[0]); \n        for (int i=1; i<v.size(); ++i) {\n            if (v[i] >= lis[n]) {\n                lis.push_back(v[i]); \n                n++; \n            } else {\n                int idx = getPos(v[i], lis); \n                lis[idx] = v[i]; \n            }\n        }\n        return v.size() - lis.size(); \n    }\npublic:\n    int kIncreasing(vector<int>& arr, int k) {\n        int ans = 0; \n        for (int i=0; i<k; ++i) {\n            vector<int>temp; \n            for (int j=i; j<arr.size(); j+=k) {\n                temp.push_back(arr[j]); \n            }\n            ans += process(temp); \n        }\n        return ans; \n    }\n};\n\n```
['Binary Tree']