← All problemsSign in

Clean The Sequence

CodeChefRating 1938Open on judge ↗

The **ugliness** of a sequence of size $N$ is defined as the number of pairs of neighboring elements which are not equal to each other. Formally, the ugliness of a sequence increase by $1$ if for a value of $i$, $2 \leq i \leq N$, the following condition holds true: $A_{i} \neq A_{i-1}$. Examples: - $[1, 2, 2, 3]$, ugliness is $2$. - $[2, 1, 2, 3,4]$, ugliness is $4$. You are given a sequence $

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start