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].
pin_featured(ids: list[int], featured: int) → list[int][[4,7,4,2,7],7]out[7,7,4,4,2]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.