#K86652. Minimum Crop Changes
Minimum Crop Changes
Minimum Crop Changes
You are given n plots of land in a row. Each plot is planted with a crop identified by a positive integer. Sometimes, the same crop is planted on adjacent plots, which is not desirable in the long term. Your task is to determine the minimum number of changes needed to ensure that no two adjacent plots have the same crop type.
For each change, you can replace the crop on a plot with any other type. Formally, given an array a_{1}, a_{2}, \dots, a_{n}, you must modify it so that for every index \(i\) (\(1 \leq i < n\)), the following holds:
[ a_{i} \neq a_{i+1} ]
Compute the minimum number of changes required to achieve this property.
inputFormat
The first line contains a single integer n
representing the number of plots.
The second line contains n
space-separated positive integers, where each integer represents the type of crop planted on the corresponding plot.
outputFormat
Output a single integer — the minimum number of changes required so that no two adjacent plots have the same crop.
## sample5
2 2 2 3 3
2
</p>