← 返回 bytedance 的题目列表Delete a length-k subarray to minimize the smallest valid index (sliding window variant)
类型:online_judge
Problem (Sliding Window Variant)
You are given an integer array arr of length n and an integer k. You must delete exactly one contiguous subarray of length k from arr. The remaining elements keep their relative order and are concatenated into a new array.
After deletion, you need to find the minimum valid index in the resulting array (the exact definition of valid index follows the original problem statement; this interview note references a variant and does not fully specify the validity rule).
Output the minimum valid index achievable by deleting some length-k contiguous block.
Input
Line 1: two integers n and k
Line 2: n integers representing arr
Output
A single integer: the minimum valid index after deleting a length-k block (or the designated value such as -1 if no valid index exists, per the original definition).
Constraints
1 <= n <= ?
0 <= k <= n
arr[i] range: ?
Examples
Placeholder only because the valid index definition is missing.
input:
5 2
1 2 3 4 5
output:
?
input:
3 1
2 2 2
output:
?