You are given an integer n and an integer p, representing the initial index of a target element in an array of size n with indices from n
You are also given an integer array banned containing indices that the target element can never occupy, and an integer k.
In one operation, you can select any contiguous subarray of length k and reverse it. If the target element is within this subarray, its position changes accordingly.
Return an array ans of length n, where ans[i] is the minimum number of reverse operations needed to move the target element from index p to index i, or i is unreachable.
Constraints:
n
p n
banned.length n
banned[i] n
k n
banned[i] p
All values in banned are unique.
You are given an integer n and an integer p, representing the initial index of a target element in an array of size n with indices from n
You are also given an integer array banned containing indices that the target element can never occupy, and an integer k.
In one operation, you can select any contiguous subarray of length k and reverse it. If the target element is within this subarray, its position changes accordingly.
Return an array ans of length n, where ans[i] is the minimum number of reverse operations needed to move the target element from index p to index i, or i is unreachable.
Constraints:
n
p n
banned.length n
banned[i] n
k n
banned[i] p
All values in banned are unique.