| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
- 하늘과 바람과 별과 시
- 리트코드
- Certbot/dns-route53
- ingress-nginx
- LEVEL 2
- swift
- Algorithm
- on-prem
- 코딩테스트
- 프로그래머스
- 2022
- Python
- Code Jam 2022
- 해커랭크
- leetcode
- 문제해결
- Qualification Round
- K8S
- 하늘과 바람과 별과 詩
- 파이썬
- GitLab
- 3D PRINTING
- hackerrank
- ProblemSolving
- Kubernetes
- C++
- Code Jam
- 알고리즘
- MySQL
- Today
- Total
목록리트코드 (4)
공대생의 비망록
이 문제는 보자마자 Python에 익숙한 사람이라면 누구나 쉽게 풀 수 있는 문제라는 생각이 들었다. for-loop을 통해 0부터 n까지 하나씩 확인하는 방법: (시간복잡도 O(n)이나 비효율적인 편)class Solution: def missingNumber(self, nums: List[int]) -> int: for i in range(len(nums) + 1): if i not in nums: return i set을 사용하며 쉽고 빠르게 문제를 해결하는 방법:class Solution: def missingNumber(self, nums: List[int]) -> int: comp = set(range(len(n..
멍청한 풀이: 시간복잡도 O(n^2)class Solution: def moveZeroes(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ i = len(nums) - 1; j = 0; zeros = 0; moved = 0 while i >= 0: if nums[i] != 0: zeros += 1 i -= 1 else: if zeros == 0: # if there's 0 at the end of th..
class Solution: def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None: """ Do not return anything, modify nums1 in-place instead. """ if n == 0: return if m == 0: # nums1 = nums2 # This will not meet the in-place requirement for i in range(n): # To meet the in-place requirement nums1[i] = ..
중첩 for-loop 활용 방법: class Solution: def containsDuplicate(self, nums: List[int]) -> bool: for i in range(len(nums)): for j in range(i + 1, len(nums)): if nums[i] == nums[j]: return True return False 집합 (Set) 자료구조 활용 방법: class Solution: def containsDuplicate(self, nums: List[int]) -> bool: exists = set() for num in nums..
