일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- dfs
- hash table
- HashTable
- Medium
- backtracking
- 이진트리
- 미디움
- Depth-first Search
- two pointers
- Python
- Array
- 재귀
- binary search
- tree
- 리트코드
- string
- recursive
- 중간
- leetcode
- easy
- linked list
- Binary
- 문자열
- matrix
- math
- binary tree
- 쉬움
- list
- sorting
- DP
- Today
- Total
목록leetcode (78)
부부의 코딩 성장 일기
1. 문제 링크 2. 문제 설명 1이 주어지면 A, 26이 주어지면 Z 27이 주어지면 AA, 28이 주어지면 AB 와 같은 규칙으로 수가 주어졌을 때 문자열을 반환 즉 엑셀의 n번째 열이름을 생각하면 되고 A부터 Z까지 26개이니 26진법으로 생각 26진법이면 26으로 나눈 나머지가 0부터 25까지 나옴 그런데 A~Z까지 0을 나타내는 수가 없다는 것에 유의, 즉 0이 아니라 1이 A가 되고 26이 Z가 되어 1부터 26까지 나와서 하나의 차이가 존재함 3. 처음 풀이 class Solution: def convertToTitle(self, columnNumber: int) -> str: #26으로 나눈 나머지가 0부터 25까지이니 0:'A' 부터 25:'Z'에 대응시켜둔다. #1이 주어지면 1을 뺀 ..
1. 문제 링크 https://leetcode.com/problems/intersection-of-two-linked-lists/ 2. 문제 설명 사이클이 없는 두 개의 연결 리스트(Linked List)가 주어졌을 때 교차하는 곳을 시작점으로 하는 연결 리스트를 반환하는 문제 예시) a1 → a2 → c1 → c2 → c3와 b1 → b2 → b3 → c1 → c2 → c3가 주어지면 c1에서 교차하기 때문에 연결 리스트 c1 → c2 → c3를 반환 3. 처음 풀이 a1을 시작으로 .next를 통해 한 칸 씩 앞으로 가며 끝까지 집합 seen에 저장하고 b1부터 시작하여 seen 에 있는 지 판단하여 아니면 한 칸 전진, 이미 나온 노드면 교차점으로 판단 하여 반환 시간 복잡도 O(m+n) # Def..
1. 문제 링크 https://leetcode.com/problems/binary-tree-preorder-traversal/ Binary Tree Preorder Traversal - LeetCode Can you solve this real interview question? Binary Tree Preorder Traversal - Given the root of a binary tree, return the preorder traversal of its nodes' values. Example 1: [https://assets.leetcode.com/uploads/2020/09/15/inorder_1.jpg] Input: root = [1, leetcode.com 2. 문제 설명 이진 트리의 r..
1. 문제 링크 Binary Tree Postorder Traversal - LeetCode Binary Tree Postorder Traversal - LeetCodeCan you solve this real interview question? Binary Tree Postorder Traversal - Given the root of a binary tree, return the postorder traversal of its nodes' values. Example 1: [https://assets.leetcode.com/uploads/2020/08/28/pre1.jpg] Input: root = [1,nuleetcode.com2. 문제 설명 트리 순회 위키피디아 트리 순회 - 위키백과, 우리 모두..
1. 문제 링크 https://leetcode.com/problems/single-number/ Single Number - LeetCode Can you solve this real interview question? Single Number - Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant leetcode.com 2. 문제 설명 정수로 구성된 nums가 주어졌을 때, 한 element만을 제외하곤, 모든 e..
1. 문제 링크 Linked List Cycle - LeetCode Linked List Cycle - LeetCode Can you solve this real interview question? Linked List Cycle - Given head, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by continuo leetcode.com 2. 문제 설명 주어진 연결 리스트(Linked List)가 사이클(고리)를 포함하는 지 판단하는 문제 리트 ..
1. 문제 링크 Valid Palindrome - LeetCode Valid Palindrome - LeetCode Can you solve this real interview question? Valid Palindrome - A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric cha leetcode.com 2. 문제 설명 주어진 문자열이 좌우대칭인 지 확인하여 True, False를 반환 단, 기호는 제외하고 숫자와 ..
1. 문제 링크 https://leetcode.com/problems/longest-palindromic-substring/ str: result_len = 0 #대칭인 문자열의 길이 result ='' #대칭인 문자열 if len(s)= 0 and j < n and s[i] == s[j]: i, j = i - 1, j + 1 return s[i + 1:j] for k in range(n): ans = max(helper(k, k), helper(k, k + 1), ans, key=len) # helper(k, k) for odd length, helper(k, k+1) for even length return ans 5. 배운 점 확실히 난이도가 medium인 문제들은 단순히 이중 삼중 포문으로는 ti..