| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- string
- binary search
- 문자열
- 재귀
- list
- math
- Python
- Binary
- two pointers
- Array
- linked list
- DP
- backtracking
- Depth-first Search
- matrix
- 리트코드
- hash table
- easy
- 중간
- HashTable
- tree
- 이진트리
- sorting
- leetcode
- recursive
- Medium
- 쉬움
- binary tree
- dfs
- 미디움
- Today
- Total
목록분류 전체보기 (147)
부부의 코딩 성장 일기
1. 문제 링크 https://leetcode.com/problems/length-of-last-word/ 2. 문제 설명 단어와 공백으로 구성된 문자열 s가 주어졌을 때, 가장 마지막 단어의 길이를 반환 예시) s = "Hello World", output: 5 (마지막 단어인 "World"의 길이 5 반환) 3. 처음 풀이 문자열에 대한 관련 함수를 이미 알고 있어서, 간단하게 해결. s의 양쪽 공백을 없애고, ' ' 기준 split을 한 후, 마지막 element의 lenght를 반환 class Solution: def lengthOfLastWord(self, s: str) -> int: return len(s.strip().split(' ')[-1]) # 양 쪽 공백을 없애고, ' '기준으로 s..
1. 문제 링크 Search Insert Position - LeetCode Search Insert Position - LeetCode Can you solve this real interview question? Search Insert Position - Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must w leetcode.com 2. 문제 설명 정수가 오름차순으로 정렬된 리스트와 하나의 정수가 주어졌을 때 정수를 리스트에..
1. 문제 링크 https://leetcode.com/problems/remove-duplicates-from-sorted-array/ 2. 문제 설명 이번엔 좋아요(13K)보다 싫어요(17.2K)가 더 많지만 그럼에도 상위에 있는 문제 오름차순으로 sort된 nums라는 배열이 있을 때, 중복이 없도록 array를 쌓고, unique 배열의 가장 마지막 index를 반환. 간단해보이지만, 전제조건이 "in-place"로, 기존의 데이터 구조를 변경하지 않고 정렬 또는 변환 작업을 수행해야 함 예시1) nums = [1,1,2] 일 때, nums = [1,2,_]로 변환하고, 2의 index인 1를 반환 예시2) nums = [0,0,1,1,1,2,2,2,3,3,4] 일 때, nums = [0,1,2,3..
1. 문제 링크 Remove Element - LeetCode Remove Element - LeetCode Can you solve this real interview question? Remove Element - Given an integer array nums and an integer val, remove all occurrences of val in nums in-place [https://en.wikipedia.org/wiki/In-place_algorithm]. The order of the elements may be changed. Then r leetcode.com 2. 문제 설명 int가 담긴 리스트 nums와 int인 val이 주어졌을 때, nums에서 val은 모두 제외하고 남은..
1. 문제 링크 https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string/ Find the Index of the First Occurrence in a String - LeetCode Can you solve this real interview question? Find the Index of the First Occurrence in a String - Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Exam..
1. 문제 링크 https://leetcode.com/problems/merge-two-sorted-lists/ Merge Two Sorted Lists - LeetCode Can you solve this real interview question? Merge Two Sorted Lists - You are given the heads of two sorted linked lists list1 and list2. Merge the two lists into one sorted list. The list should be made by splicing together the nodes of the first two lists leetcode.com 2. 문제 설명 linked list 두 개가 주어졌을 ..
1. 문제 링크 https://leetcode.com/problems/valid-parentheses/ 2. 문제 설명 (){}[]로만 구성된 string이 주어졌을 때 아래 3가지 요건을 다 만족하는지 판단 - True or False 반환 열린 괄호 ( { ] 는 같은 유형의 괄호에 의해 닫혀야 한다. 열린 괄호는 올바른 순서로 닫혀야 한다. 각 닫는 괄호는 동일 유형의 열린 괄호와 대응해야 한다. 예시) "()" true, "()[]{}" true, "(]" false 3. 처음 풀이 true인 string은 무조건 [], {}, () 중 하나의형태를 포함하고 있다. 단순하게 열고 닫는 괄호 이웃한 것을 한 쌍 한쌍 삭제하는 구조 class Solution: def isValid(self, s: s..
1. 문제 링크 Longest Common Prefix - LeetCode Longest Common Prefix - LeetCode Can you solve this real interview question? Longest Common Prefix - Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: strs = ["flower","flow" leetcode.com 2. 문제 설명 여러 문자열을 포함한 리스트가 주어졌을 때 모든 문자열의 앞에서부터 최대한 긴 공통 ..