Question bank › Arrays
Dsa Arrays Medium

Consecutive Unique Count

Given an array of integers, write a program that counts the number of unique consecutive elements in the array. A consecutive segment is defined as one or more elements that are the same and appear together. Input Format: - The first line contains an integer n (1 <= n <= 1000), the number of elements in the array. - The second line contains n integers separated by spaces, representing the elements of the array. Output Format: - Output a single integer, the count of unique consecutive elements. Example Input: 5 1 1 2 2 3 Example Output: 3

Key concepts

arrayscountingiteration

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 InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.