728x90
https://leetcode.com/problems/find-the-difference-of-two-arrays
class Solution:
def findDifference(self, nums1: List[int], nums2: List[int]) -> List[List[int]]:
result = [[], []]
all = list(set(nums1 + nums2))
for i in all:
if i in nums1 and i in nums2:
continue
elif i in nums1:
result[0].append(i)
elif i in nums2:
result[1].append(i)
return result
728x90
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 1748. Sum of Unique Elements (0) | 2024.03.04 |
---|---|
[Leetcode] 2405. Optimal Partition of String (0) | 2024.03.04 |
[Leetcode] 2418. Sort the People (0) | 2024.03.02 |
[Leetcode] 1817. Finding the Users Active Minutes (0) | 2024.02.28 |
[Leetcode] 2657. Find the Prefix Common Array of Two Arrays (1) | 2024.02.28 |