Question bank › Greedy
Dsa Greedy Medium

Colorful Marker Arrangement

You have a set of markers, each with a specific color represented by an integer. Your task is to arrange these markers in such a way that the number of adjacent markers with the same color is minimized. You may choose to rearrange the markers in any order. Given an array of integers, where each integer represents a color, return the minimum number of adjacent markers that would have the same color after optimal arrangement. Input Format: - The first line contains an integer n (1 ≤ n ≤ 100) - the total number of markers. - The second line contains n space-separated integers representing the colors of the markers. Output Format: - A single integer - the minimum number of adjacent markers with the same color after arrangement. Example: Input: 5 1 2 2 3 3 Output: 0

Key concepts

greedysortingarrays

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.