Write common_values(a: list[int], b: list[int]) -> list[int] that returns every value appearing in both lists, each value once, in increasing order.
common_values([5, 1, 3, 3, 9], [3, 7, 5, 5]) # [3, 5]
common_values([1, 2], [3, 4]) # []
0 <= len(a), len(b) <= 2 * 10^5; values are in[-10^9, 10^9]and may repeat.[x for x in a if x in b]hides a second loop:x in bscans all ofb, so it's O(len(a) * len(b)).- ⭐ Bonus: a speed test with 200,000 values per list earns a star in O(n log n). Slower correct code still passes.
Show hint
x in some_set is O(1) on average, x in some_list is O(n). Turn the lists into sets first.