일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- binary search
- binary tree
- Binary
- 재귀
- list
- easy
- HashTable
- 중간
- Depth-first Search
- linked list
- string
- 문자열
- matrix
- two pointers
- 이진트리
- sorting
- hash table
- backtracking
- 미디움
- Array
- recursive
- Medium
- 쉬움
- math
- Python
- tree
- dfs
- 리트코드
- leetcode
- DP
- Today
- Total
목록easy (39)
부부의 코딩 성장 일기
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. 문제 설명 여러 문자열을 포함한 리스트가 주어졌을 때 모든 문자열의 앞에서부터 최대한 긴 공통 ..
1. 문제 링크 https://leetcode.com/problems/roman-to-integer/ 2. 문제 설명 문제 자체는 심플, 로마 숫자를 정수로 반환하는 함수 (I, V, X ,L, .. 에 대응되는 정수값은 제공이 된다) 다만 숫자로 변환되는 규칙이 약간 생소 → 알고리즘 보다는 규칙을 찾는게 핵심 예시) II : 1+1=2, XII : 10+1+1=12, XXVII : 10+10+2+5=27 헷갈리는 규칙 4는 IIII라 쓰지 않고, IV로 표현 - 5에서 1을 뺀 값으로 작성 I는 4,9를 만들기 위해 V,X 앞에 등장할 수 있고, X는 40,90을 만들기 위해 L,C앞에 등장 가능 3. 처음 풀이 로마 문자를 key, 대응되는 정수를 value로 한 dictionary를 사전에 정의를..
1. 문제 링크 Palindrome Number - LeetCode Palindrome Number - LeetCode Can you solve this real interview question? Palindrome Number - Given an integer x, return true if x is a palindrome, and false otherwise. Example 1: Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left. Ex leetcode.com 2. 문제 설명 주어진 int를 뒤에서 앞으로 읽었을 때 같은 정수인 지 판단하는 문제 예시) int=121 이면 ..
1. 문제 링크 https://leetcode.com/problems/two-sum/ 2. 문제 설명 list와 target 숫자가 주어졌을 때, list의 두 수를 더했을 때 target 숫자가 되는, index list를 반환하는 문제 예시) nums = [2,7,11,15], target = 9 → output [0,1] 3. 처음 풀이 이중 for문을 돌려서, nums[i]와 nums[j]를 더한 게 target이면 index를 반환 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]+num..