| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- 알고리즘
- Code Jam
- 해커랭크
- 리트코드
- 하늘과 바람과 별과 시
- K8S
- Count Monobit Integers
- LEVEL 2
- 파이썬
- MySQL
- C++
- Algorithm
- 2022
- hackerrank
- 문제해결
- swift
- Qualification Round
- ProblemSolving
- ProblemSoving
- 3D PRINTING
- First Unique Character in a String
- Kubernetes
- leetcode
- 코딩테스트
- 하늘과 바람과 별과 詩
- Code Jam 2022
- 프로그래머스
- Python
- GitLab
- Today
- Total
목록Programming Language/Python (12)
공대생의 비망록
멍청한 풀이: 시간복잡도 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..
중첩 for-loop 사용: class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: for i in range(len(nums)): for j in range (i + 1, len(nums)): if nums[i] + nums[j] == target: return [i, j]시간복잡도 개선을 위해 Dictionary 자료구조를 활용하는 방식: class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: desiredTarget = {..
