- Today
- Total
목록스터디/코테 (223)
작심삼일
문제 링크: https://leetcode.com/problems/trim-a-binary-search-tree/ 문제 Given the root of a binary search tree and the lowest and highest boundaries as low and high, trim the tree so that all its elements lies in [low, high]. Trimming the tree should not change the relative structure of the elements that will remain in the tree (i.e., any node's descendant should remain a descendant). It can be prove..
문제 링크: https://leetcode.com/problems/search-in-a-binary-search-tree/ 문제 You are given the root of a binary search tree (BST) and an integer val. Find the node in the BST that the node's value equals val and return the subtree rooted with that node. If such a node does not exist, return null. 조건 The number of nodes in the tree is in the range [1, 5000]. 1
문제 링크: https://leetcode.com/problems/spiral-matrix-ii/ 문제 Given a positive integer n, generate an n x n matrix filled with elements from 1 to $n^2$ in spiral order. 조건 1
문제 링크: https://leetcode.com/problems/shift-2d-grid/ 문제 Given a 2D grid of size m x n and an integer k. You need to shift the grid k times. In one shift operation: Element at grid[i][j] moves to grid[i][j + 1]. Element at grid[i][n - 1] moves to grid[i + 1][0]. Element at grid[m - 1][n - 1] moves to grid[0][0]. Return the 2D grid after applying shift operation k times. 조건 m == grid.length n == gr..
문제 링크: https://leetcode.com/problems/kth-largest-element-in-a-stream/ 문제 Design a class to find the $k^{th}$ largest element in a stream. Note that it is the $k^{th}$ largest element in the sorted order, not the $k^{th}$ distinct element. Implement KthLargest class: KthLargest(int k, int[] nums) Initializes the object with the integer k and the stream of integers nums. int add(int val) Appends t..
문제 링크: https://leetcode.com/problems/last-stone-weight/ 문제 You are given an array of integers stones where stones[i] is the weight of the ith stone. We are playing a game with the stones. On each turn, we choose the heaviest two stones and smash them together. Suppose the heaviest two stones have weights x and y with x
문제 링크: https://leetcode.com/problems/3sum-with-multiplicity/ 문제 Given an integer array arr, and an integer target, return the number of tuples i, j, k such that i < j < k and arr[i] + arr[j] + arr[k] == target. As the answer can be very large, return it modulo 109 + 7. 조건 3
문제 링크: https://leetcode.com/problems/container-with-most-water/ 문제 You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]). Find two lines that together with the x-axis form a container, such that the container contains the most water. Return the maximum amount of water a container can store. No..