Algorithm
-
[Leetcode] 700. Search in a Binary Search Tree 문제 풀이Algorithm/문제풀이 2022. 4. 14. 12:03
https://leetcode.com/problems/search-in-a-binary-search-tree/ Search in a Binary Search Tree - LeetCode 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 문제 내용 바이너리 서치 트리가 주어지는 데 val이랑 같은 값을 가진 노드 출력 Example 1: Input: root = [4,2,7,1,3], val = 2 Output: [2,1,3] Example 2: Input: root = [4,2,7..
-
[Leetcode] 59. Spiral Matrix II 문제 풀이Algorithm/문제풀이 2022. 4. 13. 14:00
https://leetcode.com/problems/spiral-matrix-ii/ Spiral Matrix II - LeetCode 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 문제 내용 달팽이 처럼 진행하는 대로 배열을 만들기 Example 1: Input: n = 3 Output: [[1,2,3],[8,9,4],[7,6,5]] Example 2: Input: n = 1 Output: [[1]] Constraints: 1 = 0 and !mat[r][c]) { mat[r..
-
[Leetcode] 289. Game of Life 문제 풀이Algorithm/문제풀이 2022. 4. 12. 13:33
https://leetcode.com/problems/game-of-life/ Game of Life - LeetCode 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 문제 내용 주위 8방향을 보고 현재 내 상태를 갱신하는 게임 규칙은 아래와 같다. Any live cell with fewer than two live neighbors dies as if caused by under-population. Any live cell with two or three live neig..
-
[Leetcode] 1260. Shift 2D Grid 문제 풀이Algorithm/문제풀이 2022. 4. 11. 16:44
https://leetcode.com/problems/shift-2d-grid/ Shift 2D Grid - LeetCode 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차원 배열을 k만큼 shift한 결과를 return Example 1: Input: grid = [[1,2,3],[4,5,6],[7,8,9]], k = 1 Output: [[9,1,2],[3,4,5],[6,7,8]] Example 2: Input: grid = [[3,8,1,9],[19,7,2,5..
-
[Leetcode] 682. Baseball Game 문제 풀이Algorithm/문제풀이 2022. 4. 10. 21:53
https://leetcode.com/problems/baseball-game/ Baseball Game - LeetCode 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 문제 내용 베이스볼 게임을 규칙대로 하는 데 규칙대로 하고 마지막에 최종 점수를 모두 합산한 금액 리턴 An integer x - Record a new score of x. "+" - Record a new score that is the sum of the previous two scores. It is ..
-
[Leetcode] 347. Top K Frequent Elements 문제 풀이Algorithm/문제풀이 2022. 4. 9. 22:42
https://leetcode.com/problems/top-k-frequent-elements/ Top K Frequent Elements - LeetCode 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 문제 내용 빈도수가 높은 순서대로 k번째까지 숫자를 출력하는 문제 Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] Example 2: Input: nums = [1], k = 1 Output: [1] Constrai..
-
[Leetcode] 703. Kth Largest Element in a Stream 문제 풀이Algorithm/문제풀이 2022. 4. 8. 17:32
https://leetcode.com/problems/kth-largest-element-in-a-stream/ Kth Largest Element in a Stream - LeetCode 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 문제 내용 데이터가 계속 추가되는 상황에서 k번째 큰 수를 return 하는 문제 Example 1: Input ["KthLargest", "add", "add", "add", "add", "add"] [[3, [4, 5, 8, 2]], [3],..
-
[Leetcode] 1046. Last Stone Weight 문제 풀이Algorithm/문제풀이 2022. 4. 7. 12:52
https://leetcode.com/problems/last-stone-weight/ Last Stone Weight - LeetCode 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 문제 내용 각 돌에 weight가 있고 2개의 돌이 부딫히면 weight 가 차이만큼 줄어드는 돌이 하나가 생긴다. 최종적으로 1개가 남을 때 까지 계속 할 때 최소 weight 구하는 문제 만약 하나도 남지 않으면 return 0 Example 1: Input: stones = [2,7,4,1..