Question bank › Hashing
Dsa Hashing Easy

IoT Device State Streaks

An IoT hub logs device states: 'DeviceID State'. A 'streak' is a consecutive sequence of the same state for a specific device. Find the DeviceID that achieved the longest single streak of the same state across the entire log. If there is a tie in streak length, pick the DeviceID that appears first in the log. Example: Input: 6 D1 ON D1 ON D2 OFF D1 ON D2 OFF D2 OFF Output: D1 (D1 has a streak of 2 'ON's at the start. D2 also has a streak of 2 'OFF's at the end, but D1 appeared in the log first).

Key concepts

hashingiterationstate tracking

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.