일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- list
- recursive
- Array
- easy
- 재귀
- two pointers
- 문자열
- Depth-first Search
- HashTable
- Python
- Medium
- 리트코드
- 중간
- DP
- matrix
- string
- Binary
- sorting
- 미디움
- math
- leetcode
- 쉬움
- hash table
- backtracking
- binary tree
- 이진트리
- linked list
- dfs
- tree
- binary search
- Today
- Total
목록math (16)
부부의 코딩 성장 일기
1. 문제 링크 https://leetcode.com/problems/gray-code/description/ Gray Code - LeetCode Can you solve this real interview question? Gray Code - An n-bit gray code sequence is a sequence of 2n integers where: * Every integer is in the inclusive range [0, 2n - 1], * The first integer is 0, * An integer appears no more than once in the sequence, leetcode.com 2. 문제 설명 n-bit gray code sequence는 아래 조건을 만족하..
1. 문제 링크 https://leetcode.com/problems/happy-number/ Happy Number - LeetCode Can you solve this real interview question? Happy Number - Write an algorithm to determine if a number n is happy. A happy number is a number defined by the following process: * Starting with any positive integer, replace the number by the sum of the squar leetcode.com 2. 문제 설명 주어진 수가 happy 넘버인지 따져서 True, False 반환 여기서 h..
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/add-two-numbers/ Add Two Numbers - LeetCode Can you solve this real interview question? Add Two Numbers - You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and leetcode.com 2. 문제 설명 두 개의 연결리스트는 역순으로 된 숫자를 나타내고, 각 노드는 한 ..

1. 문제 링크 https://leetcode.com/problems/pascals-triangle-ii/ Pascal's Triangle II - LeetCode Can you solve this real interview question? Pascal's Triangle II - Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: [https leetcode.com 2. 문제 설명 rowIndex 라는 정수가 주어졌을 때, Pas..
1. 문제 링크 https://leetcode.com/problems/climbing-stairs/ 2. 문제 설명 계단을 n steps에 거쳐 올라가며, 한번에 1 or 2 steps 씩밖에 오르지 못할 때, n개 계단을 오르는 방법의 수를 반환 예시1) n=2 이면 1step + 1step / 2steps 이렇게 두가지 방법이 가능하므로 2를 반환 예시2) n=3 이면 1step + 1step + 1step / 1step + 2steps / 2steps + 1steps 세 방법이 가능하므로 3을 반환 → 규칙을 찾아야하는 문제 3. 처음 풀이 2~7 steps 까지를 나열해보며 규칙을 찾았다. (물론 더 쉬운 규칙이 있었음) 3 step = 1 step으로 3번 움직이거나, 2step과 1step으로..
1. 문제 링크 https://leetcode.com/problems/add-binary/ 2. 문제 설명 이진법으로 구성된 두개의 문자열 a,b가 주어졌을 때, 두 개의 합을 이진법으로 반환 예시) a= "11", b= "1"이면 십진법으로 3+1= 4이고, 이를 다시 이진법으로 반환한 "100"을 반환 3. 처음 풀이 만약 두 문자열이 0이면 0을 반환, 두 문자열을 더한 값을 십진법으로 반환하고 → 다시 이진법으로 변환하는 식으로 풀이 "11"과 "1"을 더한 "12"를 십진법으로 변환하면, 2*1 + 1*2^1 = 4 4를 계속 2로 나누면서 이진법으로 변환 result = '' (sum_num = 4) result = '0' (sum_num = 2) result = '00' (sum_num = ..
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를 사전에 정의를..