| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 30 | 31 |
- tree
- list
- string
- HashTable
- matrix
- 문자열
- dfs
- leetcode
- Depth-first Search
- 중간
- Binary
- 미디움
- 이진트리
- Array
- two pointers
- Medium
- hash table
- linked list
- binary search
- recursive
- Python
- 쉬움
- backtracking
- DP
- 재귀
- sorting
- 리트코드
- easy
- math
- binary tree
- Today
- Total
목록분류 전체보기 (147)
부부의 코딩 성장 일기
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에서 왼쪽 → 오른쪽으로..
1. 문제 링크 https://leetcode.com/problems/binary-tree-level-order-traversal/ - LeetCode Can you solve this real interview question? - 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. 문제 설명 이진 트리의 각 레벨마다 노드 값을 모두 담은 리스트를 반환하는 것 예시) 아래 트리가 주어지면 [[3],[9,20],[15,7]]를 반환 3 / \ 9 20 / \ 15 7 3. 처음..
1. 문제 링크 https://leetcode.com/problems/add-digits/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. 문제 설명 정수 num이 주어졌을 때, 반복해서 각 자릿수를 더하여, 더한 값이 한자리가 될 때까지 반복하여, 해당 값을 반환 예시) num=38이라면, 3과 8을 더하면 11. 11은 두자리수이..
1. 문제 링크 https://leetcode.com/problems/validate-binary-search-tree/ Validate Binary Search Tree - LeetCode Can you solve this real interview question? Validate Binary Search Tree - Given the root of a binary tree, determine if it is a valid binary search tree (BST). A valid BST is defined as follows: * The left subtree of a node contains only nodes with keys le leetcode.com 2. 문제 설명 주어진 tree가 이진..
데코레이터란? 파이썬에서 함수나 메소드를 감싸서 (Decorate하여), 특정 동작을 추가하거나 수정하는 기능을 말한다. 데코레이터를 사용하게 되면 코드의 재사용성을 높이고, 코드를 간결하게 유지하는 것이 가능하다. 데코레이터는 일반적으로 내부에 다른 함수를 정의하고, 그 함수를 반환하는 형태로 구현이 되는데, 이런 구조는 클로저(Closure)라 불리는 개념을 기반으로 한다. 아래의 예제를 보면, my_decorator라는 데코레이터 함수는 func이라는 인자를 받아, 그 함수를 감싸는 wrapper라는 함수를 정의하고, wrapper함수를 반환하고 있다. 이에 wrapper 함수는 클로저로써 외부함수(my_decorator)의 변수에 접근할 수 있다. @my_decorator와 같이 표시하면, 실제로..