LeetCode.Single Number II
Problem: Given a non-empty array of integers, every element appears three times except for one, which appears exactly once. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? Example 1: Input: [2,2,3,2] Output: 3 Example 2: Input: [0,1,0,1,0,1,99] Output: 99 -Summary- Solved by using dictionary. 1. for each numbe..
2020. 6. 23.
LeetCode 41. First Missing Positive
Problem: Given an unsorted integer array, find the smallest missing positive integer. Example 1: Input: [1,2,0] Output: 3 Example 2: Input: [3,4,-1,1] Output: 2 Example 3: Input: [7,8,9,11,12] Output: 1 -Summary- 1. Set first positive integer as 1 --> posNum 2. loop-through the nums and check if posNum is in the nums list. (max int: 2^31 -1) - if there is, adding 1 more value to posNum and find ..
2020. 6. 18.