Dear @leetcode,
About a month ago I submitted a test case contribution for problem: 2111. Minimum Operations to Make the Array K-Increasing
The test case is very simple and aims to test the correct handling of duplicates:
Input: arr = [2,2,2,3,3,4,2,2,2], k = 1
Output: 3
There was no update from @leetcode for the submission for a month - and now the test case submissions shows as Rejected.
Meanwhile, the Java code that is pasted below is still accepted today by the judge - although the solution is wrong, as it does not handle duplicates correctly and fails the simple test case above.
I wonder if you could help me understand: why is @leetcode rejecting a test case which helps differentiate correct solutions from incorrect ones?
Thank you.
class Solution {
public int kIncreasing(int[] arr, int k) {
int longest = 0;
for (int i = 0; i < k; ++i) {
List<Integer> mono = new ArrayList<>();
for (int j = i; j < arr.length; j += k)
if (mono.isEmpty() || mono.get(mono.size() - 1) <= arr[j])
mono.add(arr[j]);
else {
int p = Collections.binarySearch(mono, arr[j] + 1);
mono.set(p < 0 ? (-p - 1) : p, arr[j]);
}
longest += mono.size();
}
return arr.length - longest;
}
}