LeetCode 350. Intersection of Two Arrays II
Problem: Given two arrays, write a function to compute their intersection. Example 1: Input: nums1 = [1,2,2,1], nums2 = [2,2] Output: [2,2] Example 2: Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] Output: [4,9] -Summary- Using the dictionary 1. Create a dictionary to hold an all numbers as a 'key' in the first nums1 list (Count +1 for each key) 2. Loop the second nums2 list and only append to answ..
2020. 5. 24.
LeetCode 217. Contains Duplicate
Problem Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct. Example 1: Input: [1,2,3,1] Output: true Example 2: Input: [1,2,3,4] Output: false Example 3: Input: [1,1,1,3,3,4,3,2,4,2] Output: true -Summary- 1. Compare the length of the orig..
2020. 5. 23.