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..
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
Question Given a non-negative integer x, compute and return the square root of x. Since the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned. Note: You are not allowed to use any built-in exponent function or operator, such as pow(x, 0.5) or x ** 0.5. 음이 아닌 정수 x가 주어졌을 때, 제곱근 x를 구하여라. 다만 제곱근 x를 구할 때 소수점 아래수는 버린다. Note: 내장 함수를 사용하면 안 ..
Question Implement pow(x, n), which calculates x raised to the power n (i.e., xn). x의 n승을 리턴하는 pow 함수를 구현하라. 제약사항 -100.0 < x < 100.0 -2^31 = 1; } } if (n < 0) { ans = (double)(1.0) / (double)(ans); } return ans; } }; // 해당 문제의 Discuss 참고 출처 : https://leetcode.com/explore/interview/card/top-interview-questions-medium/113/math/818/ Explore - LeetCode LeetCode Explore is the best place for everyone..
- Total
- Today
- Yesterday
- 러스트
- Interview
- 자료구조
- Tree
- 코딩인터뷰
- 러스트 기초
- 속초
- 솔직후기
- Problem Solving
- 속초 맛집
- 트리
- 러스트 배우기
- Medium
- 인터뷰
- rust
- LeetCode
- DP
- C++
- ProblemSolving
- 반드시 알아야 할 자료구조
- 내돈내산
- 맛집
- 러스트 입문
- 알고리즘
- coding interview
- PS
- algorithm
- 리트코드
- 기술면접
- interview question
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
