Practice · 1 of 5
Bead Necklace
CHALLENGE
Difficulty: intermediate+25 XP
**Description:** A necklace of n beads (n >= 2) in a circle; bead i has color c[i]
(1..100). Count the adjacent pairs (including bead n next to bead 1) with
DIFFERENT colors.
**Input:** Line 1: n (2 <= n <= 100000). Line 2: n integers c[i].
**Output:** One integer — the number of color-changing adjacencies.
**Example:** 4 / 1 2 2 1 -> 2 (1-2 and 1-2 across the closure).
Press Submit to check your solution.
Back to lesson: Practice: Mixed Mock Problems