Input: N = 6, M = 2, Positions = {2, 3}
Output: {3, 2, 1, 1, 2, 3}
Explanation: Initial array: {0, 0, 0, 0, 0, 0}
After first operation: {2, 1, 0, 1, 2, 3}
where each element to the right of 2nd index and each element to its left follow the given condition
After second operation: {3, 2, 1, 0, 1, 2}
Thus, maximum value of each index among all the operations: {3, 2, 1, 1, 2, 3}
Input: N = 4, M = 3, Positions = {3, 2, 1}
Output: {3, 2, 1, 2}
Explanation: Initial array: {0, 0, 0, 0}
After first operation: {3, 2, 1, 0}
After second operation: {2, 1, 0, 1}
After third operation: {1, 0, 1, 2}
Thus, Maximum: {3, 2, 1, 2}
Based on the above observation, the solution is to find the indices closest to the ends of the array (say x and y) which are set to 0 at any of the operations. The maximum value for each index will be the maximum distance from any of x and y.