728x90
https://leetcode.com/problems/find-common-elements-between-two-arrays
class Solution:
def findIntersectionValues(self, nums1: List[int], nums2: List[int]) -> List[int]:
result = [0, 0]
for i in range(0, len(nums1)):
if nums1[i] in nums2:
result[0] += 1
for i in range(0, len(nums2)):
if nums2[i] in nums1:
result[1] += 1
return result
728x90
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 1347. Minimum Number of Steps to Make Two Strings Anagram (1) | 2024.02.24 |
---|---|
[Leetcode] 2913. Subarrays Distinct Element Sum of Squares I (0) | 2024.02.24 |
[Leetcode] 804. Unique Morse Code Words (0) | 2024.02.23 |
[Leetcode] 1684. Count the Number of Consistent Strings (0) | 2024.02.23 |
[Leetcode] 1832. Check if the Sentence Is Pangram (0) | 2024.02.22 |