Pin featured product to front
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.
0:00 of about 13 min
solution.py
InputExpectedGot
[[4,7,4,2,7],7][7,7,4,4,2]not run yetsample