
😎풀이
- 각
nums 순회
1-1. 교집합 확인
1-2. 교집합 중 최소 값 반환
- 존재하지 않다면
-1 반환
function getCommon(nums1: number[], nums2: number[]): number {
const set1 = new Set(nums1)
const set2 = new Set(nums2)
for(const num of set1) {
if(!set2.has(num)) continue
return num
}
return -1
};