Filter Pins by Excluded IDs
Problem statement
For this exercise, assume each pin is identified by a string and excludedPins lists the IDs to remove.
Given pins and excludedPins, return every entry of pins whose ID is absent from excludedPins. Match complete IDs exactly and case-sensitively. Preserve the input order and every occurrence of an allowed ID. Repeated excluded IDs have the same effect as one occurrence. Return an empty array if no entries remain.
Function
filterPins(pins: String[], excludedPins: String[]) → String[]Examples
Example 1
pins = ["p3","p1","p3","p2"]excludedPins = ["p1"]return = ["p3","p3","p2"]The entry p1 is excluded. Both occurrences of p3 remain, in their original order before p2.
Example 2
pins = ["A","a","x"]excludedPins = ["a","a","missing"]return = ["A","x"]Matching is case-sensitive, so a is removed while A remains. Repeating a in the exclusion list has no additional effect; missing does not occur in pins.
Example 3
pins = []excludedPins = ["p1"]return = []There are no input pins, so the result is empty.
Constraints
0 <= pins.length <= 100000.0 <= excludedPins.length <= 100000.- Every ID has length from 1 through 40 and contains only ASCII letters, digits, hyphens, or underscores.