일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 리트코드
- recursive
- leetcode
- 미디움
- Depth-first Search
- list
- linked list
- hash table
- math
- easy
- dfs
- binary tree
- matrix
- string
- backtracking
- Binary
- Python
- two pointers
- 쉬움
- DP
- sorting
- 재귀
- Array
- 이진트리
- Medium
- HashTable
- binary search
- 중간
- 문자열
- Today
- Total
목록leetcode (78)
부부의 코딩 성장 일기
1. 문제 링크 https://leetcode.com/problems/4sum/description/ 4Sum - LeetCode Can you solve this real interview question? 4Sum - Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that: * 0 List[List[int]]: nums.sort() output = [] for i in range(len(nums)-3): if i > 0 and nums[i] == nums[i - 1]: continue # 중복된 값을 건너뛰기 for j in ra..
1. 문제 링크 https://leetcode.com/problems/3sum-closest/ 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. 문제 설명 리스트 nums와 target 수가 주어졌을 때 nums에서 서로 다른 세 개를 더하여 만들 수 있는 값 중 target과 가장 가까운 값을 반환 예시) nums = [-1,2,1,-4], target..
1. 문제 링크 https://leetcode.com/problems/integer-to-roman/submissions/ 2. 문제 설명 우리가 쓰는 정수가 주어지면 Roman 숫자로 바꾸어 return 하는 문제 아래의 기호를 이용함 I: 1 V: 5 X: 10 L: 50 L: 100 D: 500 M: 1000 이 때, I는 V,X 앞에 쓰여서 4,9를 나타냄 X는 L,C 앞에 쓰여서 40,90을 나타냄 C는 D,M 앞에 쓰여서 400,900을 나타냄 예시) 3 → III, 58 → LVIII, 1994 → MCMXCIV 3. 처음 풀이 딱히 특별한 알고리즘이 없을 것 같아서, 정수에 매칭되는 로마 문자에 대한 dictionary를 만들어두고, num 이 특정 숫자 이상이면, 그 숫자에 대한 로마 문..
1. 문제 링크 https://leetcode.com/problems/string-to-integer-atoi/ 2. 문제 설명 주어진 문자열을 숫자로 바꾸는 것 규칙 처음 나오는 공백 ''은 무시 그러다가 처음에 부호('+', '-')가 나오면 이를 최종 결과에 반영 그 외 수가 아닌 문자가 나오면 멈춤 (기본값은 0, 그 전에 수가 나와서 반영되었다면 그 값) 수가 나오기 시작했으면 그 이후에 수가 아닌 것이 나오면 멈춤 마지막으로 32bit 넘어가면, 내리거나(너무 큰 수), 올려서(너무 작은 수) 반환 예시1) "42" → 42 예시2) " -42" → -42 (공백 무시) 예시3) "4193 with words" → 4193 (수 뒤에 수 아닌 것 나오면 stop) 예시4) "-1123u3761..
1. 문제 링크 https://leetcode.com/problems/zigzag-conversion/ 2. 문제 설명 문자열과 줄 개수가 주어졌을 때, 이를 ↓↗↓↗ 로 반복 배열 한 후, 위에서 아래로 이어붙여서 반환 예시) str= "PAYPALISHIRING", numRows = 3이 주어지면 P A H N A P L S I I G Y I R 로 배열한 후, 위에서 아래로 이어붙여서 "PAHNAPLSIIGYIR"를 반환 3. 처음 풀이 46ms(97.08%), 16.48mb(36.12%) 문제 이름대로 지그재그 움직이는 아이디어 현재 가로 줄이 몇 번째인지 나타내는 변수 position과 위로 갈지 아래로 갈지 방향을 나타내는 변수 direction에 0, 1을 초기 할당함 현재 위치한 가로 줄에..
1. 문제 링크 https://leetcode.com/problems/reverse-bits/ Reverse Bits - LeetCode Can you solve this real interview question? Reverse Bits - Reverse bits of a given 32 bits unsigned integer. Note: * Note that in some languages, such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed leetcode.com 2. 문제 설명 주어진 정수를 2진법으로 나타낸 후 이를 앞뒤 역순으로 뒤집은 수를 10진법..
1. 문제 링크 LeetCode - The World's Leading Online Programming Learning Platform Excel Sheet Column Number - LeetCode Can you solve this real interview question? Excel Sheet Column Number - Given a string columnTitle that represents the column title as appears in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 leetcode.com 2. 문제 설명 A이 주어..
1. 문제 링크 https://leetcode.com/problems/majority-element/ Majority Element - LeetCode Can you solve this real interview question? Majority Element - Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists leetcode.com 2. 문제 설명 크기가 n인 배열이 주어졌을 때, majority element를 반환..