일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 |
- hash table
- sorting
- DP
- recursive
- Depth-first Search
- 미디움
- linked list
- HashTable
- easy
- math
- binary tree
- 이진트리
- 문자열
- backtracking
- tree
- two pointers
- matrix
- Binary
- string
- 재귀
- Medium
- 중간
- Python
- leetcode
- Array
- binary search
- 리트코드
- dfs
- 쉬움
- list
- Today
- Total
목록2024/02 (31)
부부의 코딩 성장 일기
추상화란? 추상화란 프로그램의 세부 구현을 감추고 필요한 부분만을 노출시키는 것을 의미한다. 추상클래스는 구현하지 않은 추상메소드를 한 개 이상 가지며, 자식 클래스에서 해당 추상 메소드를 반드시 구현하도록 강제한다. 왜 그렇게 할까? 이는 코드를 더 간결하게 만들고 모듈성을 높여 유지보수를 쉽게 만들어준다. 만약 추상클래스가 여러개의 자식 클래스를 가지고 있고, 자식 클래스에서 추상 메소드에서 정의해야 하는 내용이 다르다면, 추상클래스를 사용하는 것이 효율적이겠다. abc Library 이는 python에서 추상 베이스 클래스(ABC - Abstract Base Class)를 정의하는 데 사용된다. 즉, 추상 베이스 클래스는 일종의 템플릿으로, 특정 메서드가 반드시 파생 클래스에서 구현되어야 함을 정..

1. 문제 링크 https://leetcode.com/problems/path-sum-ii/description/ LeetCode - The World's Leading Online Programming Learning Platform 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 2. 문제 설명 이진트리의 root와 targetSum이라는 정수가 주어졌을 때, 각 노드의 합이 targetSum과 같으면서 root-to-leaf로 가는 모든 path를 구해서 list에 저장하여..

1. 문제 링크 https://leetcode.com/problems/binary-tree-level-order-traversal-ii/description/ LeetCode - The World's Leading Online Programming Learning Platform 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 2. 문제 설명 이진트리의 root가 주어졌을 때, bottom-up level order traversal을 반환 여기서 bottom-up leverl ..

production 환경에 application을 배포하다보면, 예기치못한 에러가 등장하고, 해당 에러가 정확히 어디서 발생했는지, 왜 문제가 일어났는지를 판단하는 것은 쉬운 일이 아니다. 이에, logging하는 것은 필수적이고, 문제를 디버깅하는 작업이 쉬워지게 된다. Python에 여러 logging libaray가 존재하는데, 그 중 가장 인기있는 loguru에 대해 정리해보려한다. 왜 logging library가 필요할까? 사실 print() method를 통해서 쉽게 log를 기록할 수도 있다. 하지만, print()는 아래의 단점들을 가지고 있다. (결국 print()의 단점이기도 하지만 logging library의 장점이 되겠다.) JSON과 같은 구조화된 형식이 아니기도 하고, 심각도..
Python에서 packages를 만들게 되면, __init__.py를 포함하게 된다. 다들 그렇게 코드를 작성하길래, 왜 필요한지 모른 채 그냥 __init__.py를 추가했었다. 그러다가, __init__.py를 추가하지 않고, 해당 packages를 import해서 불러오려고 하다보니, modules를 찾을 수 없다는 에러가 떴고, 그 원인이 바로 __init__.py였다 __init__.py의 역할은? __init__.py 파일은 python 패키지를 정의하는 데에 사용되는 파일이다. 주요 역할은 아래와 같은데, 1. 패키지 식별자로 사용 __init__.py 파일이 있는 디렉토리는 Python에게 패키지로 취급되어야 함을 알린다. 즉, 이 파일이 없다면 해당 디렉토리는 단순한 모듈 디렉토리로 간..

1. 문제 링크 https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ LeetCode - The World's Leading Online Programming Learning Platform 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 2. 문제 설명 preorder, inorder에 대한 array가 주어졌을 때, 여기서 preorder는 이진트리의 preorder tr..
1. 문제 링크 Ugly Number - LeetCode Ugly Number - LeetCode Can you solve this real interview question? Ugly Number - An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5. Given an integer n, return true if n is an ugly number. Example 1: Input: n = 6 Output: true Explanation: 6 = leetcode.com 2. 문제 설명 주어진 숫자가 Ugly Number인지 판별하는 문제 Ugly Number란 오직 2, 3, 5 세 소수의 곱으로만 이루어..

1. 문제 링크 https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ LeetCode - The World's Leading Online Programming Learning Platform 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 2. 문제 설명 binary tree의 root가 주어졌을 때, level 별로 zigzag 순서로 nodes의 값을 적재하여 반환 level 0에서 왼쪽 → 오른쪽으로..