Your question is Common Elements From Two Lists. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Exiger DDI may compare supplier or entity identifiers from two screening results. Given two lists of values, return the unique values that occur in both lists, preserving the order in which they first appear in the first list.
Implement common_elements(list1, list2):
list1 and list2 are lists of integers.list1.Example 1
Input: list1 = [4, 2, 7, 2, 9], list2 = [8, 2, 4, 2]
Output: [4, 2]
Explanation: 4 and 2 occur in both lists. The result follows their first appearance in list1, and the duplicate 2 is returned once.
Example 2
Input: list1 = [5, 1, 3], list2 = [7, 8]
Output: []
Explanation: The lists contain no shared values.
0 <= len(list1), len(list2) <= 100,000-10^9 <= list1[i], list2[i] <= 10^9def common_elements(list1, list2):