1. What I learned
Finding common values in lists
Converting a list to a set clears duplicate values and the ‘&’ operator selects common values from lists.
2. How I sloved
Common values in the lists had to be found. So I just used ‘set’ and the ‘&’ operator.
3. Code
class Solution:
def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
return set(nums1) & set(nums2)
4. Result
Runtime : 44 ms(72.73%), Memory usage : 14.3 MB(100.00%)
(Runtime can be different by a system even if it is a same code.)