Your question is Intersection of Two Arrays. 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.
A UC Santa Barbara course-planning tool receives two arrays of course codes from different search results. Return the distinct course codes that appear in both arrays, preserving the order of their first appearance in codes1.
Implement intersection(codes1, codes2), where both inputs are arrays of integers representing course codes. Return an array containing each shared value exactly once. If a value occurs multiple times in either input, it must appear at most once in the output. The output order must follow the first occurrence of each value in codes1.
def intersection(codes1, codes2):