#C7931. Minimum Changes to Make Staircase Symmetric
Minimum Changes to Make Staircase Symmetric
Minimum Changes to Make Staircase Symmetric
You are given a staircase with N steps, where each step has a certain height given by an array H. Your task is to determine the minimum number of step modifications needed so that the staircase becomes symmetric. A staircase is symmetric if for every index i (0-indexed), the condition
\( H[i] = H[N-i-1] \)
holds true.
For example, if the staircase is described by N = 5
and H = [1, 3, 2, 3, 1]
, it is already symmetric and no changes are needed. However, if instead you have H = [1, 5, 3, 2, 5, 1]
for N = 6
, you will need to adjust one step to achieve symmetry.
inputFormat
The first line of input contains a single integer N representing the number of steps in the staircase. The second line contains N space-separated integers which denote the heights of the steps.
outputFormat
Output a single integer: the minimum number of changes required to make the staircase symmetric.
## sample5
1 3 2 3 1
0
</p>