ans
of length n
with all elements set to -1
to store the minimum number of operations required to move the 1
to each position.p
with a count of 0
operations.(current_position, operations)
.current_position
by reversing a subarray of size k
.current_position
and is not banned.ans[index]
with operations + 1
if it is not already visited, and enqueue (index, operations + 1)
.ans
array.