본문 바로가기

분류 전체보기

(440)
[비트연산] 릿코드 231 Easy 'Power of Two' (Python) https://leetcode.com/problems/power-of-two/ Power of Two - 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 1. n이 2의 지수여야 하므로 n을 2진수로 바꾸면 모두 1이다 2. n에서 1을 빼면 10, 100000 처럼 나오므로 n-1과 n을 & 비트연산하면 무조건 0이 나올 것이다 3. n이 0보다 크고, n&(n-1)이 0이면 True가 나오게 한다. class Solution: def isPowerOfTwo(s..
[이분탐색] 릿코드 153 Medium 'Find Minimum in Rotated Sorted Array' (Python) https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/ Find Minimum in Rotated Sorted Array - 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 1. 배열의 최소 요소를 반환하라고 했으므로 min 함수 사용 class Solution: def findMin(self, nums: List[int]) -> int: return min(nums)
[이분탐색] 릿코드 Medium 74 'Search a 2D Matrix' (Python) https://leetcode.com/problems/search-a-2d-matrix/ Search a 2D Matrix - 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 1. 각 행에 target 값이 있으면 true class Solution: def searchMatrix(self, matrix: List[List[int]], target: int) -> bool: for i in matrix: if target in i: return True retur..
[이분탐색] 릿코드 Medium 33 'Search in Rotated Sorted Array' (Python) https://leetcode.com/problems/search-in-rotated-sorted-array/ Search in Rotated Sorted Array - 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 1. nums에서 target의 인덱스 값을 찾아라 2. target 값이 없으면 -1 class Solution: def search(self, nums: List[int], target: int) -> int: if target in nums: ..
[이분탐색] 릿코드 Medium 34 'Find First and Last Position of Element in Sorted Array' (Python) https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/ Find First and Last Position of Element in Sorted Array - 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 1. 파이썬의 bisect 라이브러리를 활용 2. target이 nums에 있다면 정답을 반환하고 없으면 [-1,-1]을 반환함 from bisect impor..
[에세이][독후감] “내가 확실히 아는 것들” - 오프라 윈프리 2021.07.25 ~ 2021.07.25 Score ❤❤ 집 앞 북카페 가서 책을 고르다가 제목에 끌려 읽게 되었다. 오프라 윈프리는 미국 방송인이다. 이름은 많이 들어봤는데 어디에 나왔는지는 잘 몰라서 인터넷에서 찾아봤다. [1장. 기쁨] "자신이 별 네 개나 다섯 개를 줄 만한 즐거움을 누리고 있다는 것을 자각하거나 스스로 그런 순간을 만들어내다 보면 복이 저절로 따라오게 마련이다." 내 행복은 스스로가 만들어내는 것인 것 같다. 요즘 취업 준비하느라 약간 힘든데 힘내서 긍정적으로 생각해야겠다. 미래도 중요하지만 지금 이 순간순간을 소중히 보내고 즐겁게 사는 것이 중요한 것 같다. "삶을 황홀한 보물로 가득 채우고 싶다면 그 보물을 감상할 잠시의 시간만 내면 된다." 나만의 소소한 행복을 찾고 잠깐..
[해시] 릿코드 Medium 567 'Permutation in String' (Python) https://leetcode.com/problems/permutation-in-string/ Permutation in String - 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 순서 상관없이 s2 내에 연속해서 s1의 값이 들어있으면 됨 그 값이 몇개 있는지만 확인하면 되므로 Counter 라이브러리 이용 from collections import Counter class Solution: def checkInclusion(self, s1: str, s2..
[동적계획법] 릿코드 Medium 198 'House Robber' (Python) https://leetcode.com/problems/house-robber/ House Robber - 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 1. 더하는 숫자들이 이웃하지만 않으면 됨 2. 바로 직전의 돈과 두번째 전의 돈+현재 돈 중 큰 값을 구하면 됨 3. 집이 하나만 있을 수 있음 class Solution: def rob(self, nums: List[int]) -> int: answer = [] if len(nums)==1: return nu..

LIST