Corridor Badge Coverage Problem
Corridor Badge Coverage Problem — ExecCode Hard DSA Practice
Solve the Corridor Badge Coverage problem on ExecCode. Free online hard DSA practice in Two Pointers. Write and run code in Java, C++, Python — no signup required to run.
Problem description
You are given an array badges of length n. Each value is an integer between 1 and n. For every window size w from 1 to n: Look at every contiguous group of exactly w numbers in the array. Find the smallest number that appears in all of those groups. If no such number exists, the answer is -1. Return a list of n answers, one for each window size from 1 to n. You are given: badges — the array of numbers Simple example of windows: if badges = [1, 2, 3, 4, 5] and w = 3, the groups are [1,2,3], [2,3,4], and [3,4,5]. The smallest number that appears in all three groups is 3. Full answers for that array are [-1, -1, 3, 2, 1]. For badges = [4, 4, 4, 4, 2] the answers are [-1, 4, 4, 4, 2].
Examples
Input {'badges': [1, 2, 3, 4, 5]}; Output [-1, -1, 3, 2, 1]. Input {'badges': [5, 4, 3, 2, 1]}; Output [-1, -1, 3, 2, 1]. Input {'badges': [4, 4, 4, 4, 2]}; Output [-1, 4, 4, 4, 2]
Constraints
1 <= badges.length <= 100000 1 <= badges[i] <= badges.length
Practice Corridor Badge Coverage free on ExecCode. Browse DSA problems, topic map, and placement guides.