
Question Given the root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) of all the values of the nodes in the tree. 이진 탐색 트리와 정수 k가 주어졌을 때, 모든 노드 중 k번째로 작은 값을 리턴하는 함수를 작성하라. 제약사항 The number of nodes in the tree is n. 1 right); } int kthSmallest(TreeNode* root, int k) { vector node_val_vec; AddAllElement(node_val_vec, root); return node_val_vec[k-1]; } }; Time..

Question You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition: 완전 이진트리가 주어진다면 같은 레벨의 노드를 모두 오른쪽으로 연결하는 함수를 작성하라. struct Node { int val; Node *left; Node *right; Node *next; } Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be s..

Question Given two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the same tree, construct and return the binary tree. 이진 탐색 트리의 preorder 순서와 inorder순서로 탐색한 결과인 두 배열이 주어질 때, 원래의 이진트리를 출력하라. 제약사항 1

Question Given the root of a binary tree, return the zigzag level order traversal of its nodes' values. (i.e., from left to right, then right to left for the next level and alternate between). 이진트리의 root 가 주어졌을 때 지그재그로 노드의 값을 출력하는 함수를 작성하라. 제약사항 The number of nodes in the tree is in the range [0, 2000]. -100 left){ next_level.push(top->left); } if(top->right){ next_level.push(top->right); } }els..
이 카테고리에서는 단순히 수학적 공식 혹은 지식을 깊게 다루진 않는다. 프로그래밍과 연관 지어서 유용하게 사용할 수 있는 수학적 지식을 다룬다. 1 + 2¹ + 2¹ + 2² + ... + 2ⁿ 의 수열의 합은 무엇일까? 2의 승수의 합은 등비 수열의 합이다. 등비 수열이란 일정한 비를 가지고 나열된 수열을 뜻하는데, 이 등비수열의 합의 공식은 아래와 같이 유도했다. 등비수열 Sn을 원래 순서대로 한 번, 순서를 바꿔서 한번 더해서 2로 나눈다. 아마 고등학교 수학을 배운지 한참 지난 프로그래머 직장인이라면 해당 개념을 분명히 배웠지만 잘 기억이 나지 않을 것이고, 이런 게 있었나 싶을 것이다. 그렇다면 프로그래머가 이해하기 쉽게 해당 등비 수열의 합을 이해해보자. 한 가지 훌륭한 방법은 이 값을 2진수..

Question Task Scheduler Given a characters array tasks, representing the tasks a CPU needs to do, where each letter represents a different task. Tasks could be done in any order. Each task is done in one unit of time. For each unit of time, the CPU could complete either one task or just be idle. char type의 원소로 이루어진 task배열이 주어진다. 배열의 각 task들은 CPU가 해야 하는 일이며, 각각의 letter는 각기 다른 task들을 나타낸다. Task 들은..

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 in the array. size가 n인 배열이 주어질 때, majority 한 원소를 return 하라. majority 한 원소란, 전체 배열에서 n/2 이상 등장한 원소를 뜻한다. 배열 안에 majority 원소가 항상 있다고 생각해도 좋다. 제약사항 n == nums.length 1
이 카테고리에서는 단순히 수학적 공식 혹은 지식을 깊게 다루진 않는다. 프로그래밍과 연관 지어서 유용하게 사용할 수 있는 수학적 지식을 다룬다. 1 + 2 + 3 + ... + n 의 결과는 무엇일까? 고등학교 교과과정에서 해당 식의 결과를 구하는 방법을 배웠다. 각 숫자의 나열을 수열이라 하고, 어떠한 규칙이냐에 따라 등차 혹은 등비로 나뉘었다. 해당 식의 경우 각 수열의 차가 1인 등차수열의 합이다. 해당 식은 간단하게 시그마(Σ)라는 기호를 사용하여 표현하였고, 시그마에 나오는 식의 종류나 형태에 따라 공식이 존재했다. 공식의 도출과정과 어떠한 형태로 코드에 나타날 수 있는지 프로그래머의 입장으로 다시 한번 식을 살펴보자. 먼저 공식의 도출 과정이다. 1 + 2 + 3 + ... + n을 나눠서 생..
- Total
- Today
- Yesterday
- coding interview
- 러스트
- 코딩인터뷰
- Medium
- DP
- 속초 맛집
- 트리
- ProblemSolving
- LeetCode
- 러스트 배우기
- Problem Solving
- PS
- rust
- 자료구조
- 인터뷰
- 내돈내산
- 속초
- interview question
- 기술면접
- 맛집
- 러스트 입문
- 솔직후기
- Interview
- 알고리즘
- 리트코드
- 반드시 알아야 할 자료구조
- Tree
- 러스트 기초
- algorithm
- C++
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |