[JAVA] Easy to understand O(NlogN)
very very similar to longest increasing subsequence\n\n\nclass Solution {\n    public int kIncreasing(int[] A, int k) {\n        // Longest increasing subsequen
very very similar to longest increasing subsequence\n\n```\nclass Solution {\n    public int kIncreasing(int[] A, int k) {\n        // Longest increasing subsequence for\n        // A[i]..A[i + k].. A[i + 2k]\n        int n = A.length;\n        // int[] memo = new int[n];\n        int res = 0;\n        for (int s = 0; s < k; s++) {\n            List<Integer> dp = new ArrayList<>();\n            for (int i = s; i < n; i += k){\n                \n                if (!bsearch(dp, A[i])) {\n                    dp.add(A[i]);\n                }\n                // System.out.println(A[i] + "-" + i);\n                // System.out.println(dp.toString());\n            }\n            \n            // System.out.println(dp.toString());\n            res += dp.size();\n        }\n        return n - res;\n    }\n    \n    private boolean bsearch(List<Integer> dp, int target) {\n        if(dp.isEmpty()) {\n            return false;\n        }\n        \n        int lo = 0, hi = dp.size() - 1;\n        while(lo < hi) {\n            int mid = lo + (hi - lo) / 2;\n            if (dp.get(mid) <= target) {\n                lo = mid + 1;\n            } else {\n                hi = mid;\n            }\n        }\n        \n        if (dp.get(lo) > target){\n            dp.set(lo, target);\n            return true;\n        }\n        return false;\n    }\n}\n```
['Binary Tree']