Code Room
CodingMediumcod-g1203
Subject ArraysLevel Entry–Mid~13 minCommon in Distributed systems · Algorithms & data structures interviewsIndustries Software development

Question

A merchandising rule pins a featured product to the top of search results. Given a list of product IDs in their current ranking and the featured ID, move every occurrence of the featured ID to the front while keeping the relative order of the featured copies and of all the other IDs unchanged. Return the rearranged list. Example: [4, 7, 4, 2, 7] with featured 7 becomes [7, 7, 4, 4, 2].

Implement
pin_featured(ids: list[int], featured: int) → list[int]
Examples
in[[4,7,4,2,7],7]out[7,7,4,4,2]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.