Pin featured product to front
Your task
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].
Examples
pin_featured(ids: list[int], featured: int) -> list[int]Example 1
Input
pin_featured([4, 7, 4, 2, 7], 7)Output
[7, 7, 4, 4, 2]