Algorithm/1일 1코테
-
[💕 LeetCode Python] 191. Number of 1 BitsAlgorithm/1일 1코테 2020. 10. 27. 15:28
📌 문제 및 문제풀이 leetcode.com/problems/number-of-1-bits/ Number of 1 Bits - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 📌 내 답 def hammingWeight(self, n: int) -> int: return bin(n).count('1') 📌 풀이 #비트연산 풀이 원래 값 & 원래 값 - 1 => 원래 값에서 1이 하나 빠진 값이 나옴 이걸 모든 값이 0이 될때까지 반복하면 count에 1의 총 갯수가..
-
[🤷♀️ LeetCode Python] 393. UTF-8 ValidationAlgorithm/1일 1코테 2020. 10. 27. 15:08
✍LeetCode✍ 393. UTF-8 Validation 문제 및 문제설명 UTF-8임을 검증하는 문제 leetcode.com/problems/utf-8-validation/ UTF-8 Validation - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 내가 쓴 풀이 노가다 했는데도 틀림!!! 밑에 에러가 발생한 후 걍 포기했다 ㅎ def validUtf8(self, data: List[int]) -> bool: data = [bin(i).replace('0..
-
[💕 LeetCode Python] 461. Hamming DistanceAlgorithm/1일 1코테 2020. 10. 27. 13:30
✍461. Hamming Distance✍ 문제 leetcode.com/problems/hamming-distance/ Hamming Distance - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 내 답 def hammingDistance(self, x: int, y: int) -> int: # xor은 같으면 0, 다르면 1이므로 1의 갯수를 센다. return bin(x^y).count('1') 풀이 내 답이랑 똑같음
-
[💕 LeetCode Python] 136. Single NumberAlgorithm/1일 1코테 2020. 10. 27. 13:24
LeetCode 136. Single Number 문제 및 문제설명 leetcode.com/problems/single-number/ Single Number - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 내가 쓴 답 def singleNumber(self, nums: List[int]) -> int: answer = {} #dict 생성 for i in nums: if i in answer: answer[i] += 1 else: answer[i] = 1 f..
-
[💕 LeetCode Python] 240. Search a 2D Matrix 2Algorithm/1일 1코테 2020. 10. 26. 20:10
✍ 240. Search a 2D Matrix 2 문제 leetcode.com/problems/search-a-2d-matrix-ii/submissions/ Search a 2D Matrix II - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 내가 쓴 답 def searchMatrix(self, matrix, target): for i in matrix: if target in i: return True return False 풀이 def searchMatr..
-
[🤷♀️ LeetCode Python] 167. Two Sum 2 - Input array is sortedAlgorithm/1일 1코테 2020. 10. 26. 19:30
✍ 167. Two Sum 2 - Input array is sorted 문제 및 문제설명 leetcode.com/problems/two-sum-ii-input-array-is-sorted/ Two Sum II - Input array is sorted - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 내가 쓴 답 # 시간초과로 탈락 def twoSum(self, numbers: List[int], target: int) -> List[int]: for i in..
-
[💕 LeetCode Python] 349. Intersection of Two ArraysAlgorithm/1일 1코테 2020. 10. 26. 18:33
✍LeetCode✍ 349. Intersection of Two Arrays 문제 leetcode.com/problems/intersection-of-two-arrays/submissions/ Intersection of Two Arrays - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 내가 쓴 답 def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]: answer = [] # 답안 ..
-
[💕 LeetCode Python] 704. Binary SearchAlgorithm/1일 1코테 2020. 10. 26. 14:27
리트코드 [ 704. Binary Search ] 문제 및 문제설명 leetcode.com/problems/binary-search/submissions/ Binary Search - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 내가 제출한 답 def search(self, nums: List[int], target: int) -> int: if any(i == target for i in nums): # target이랑 같은 값이 있으면 return nums..