全站内容
medium
3159. Find Occurrences of an Element in an Array
#Problem You are given an integer array nums, an integer array queries, and an integer x. For each queries[i], you need to find the index of the queries[i]ᵗʰ occurrence of x in the nums array. If there are fewer than queries[i] occurrences …
494. Target Sum
#Problem You are given an integer array nums and an integer target. You want to build an expression out of nums by adding one of the symbols '+' and '-' before each integer in nums and then concatenate all the integers. For example, if nums …
515. Find Largest Value in Each Tree Row
#Problem Given the root of a binary tree, return an array of the largest value in each row of the tree (0-indexed). https://leetcode.com/problems/find-largest-value-in-each-tree-row/ Example 1: case1Input: root = [1,3,2,5,3,null,9] Output: …
3218. Minimum Cost for Cutting Cake I
#Problem There is an m x n cake that needs to be cut into 1 x 1 pieces. You are given integers m, n, and two arrays: horizontalCut of size m - 1, where horizontalCut[i] represents the cost to cut along the horizontal line i. verticalCut of …
1705. Maximum Number of Eaten Apples
#Problem There is a special kind of apple tree that grows apples every day for n days. On the iᵗʰ day, the tree grows apples[i] apples that will rot after days[i] days, that is on day i + days[i] the apples will be rotten and cannot be …
721. Accounts Merge
#Problem Given a list of accounts where each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements are emails representing emails of the account. Now, we would like to merge …
2471. Minimum Number of Operations to Sort a Binary Tree by Level
#Problem You are given the root of a binary tree with unique values. In one operation, you can choose any two nodes at the same level and swap their values. Return the minimum number of operations needed to make the values at each level …
855. Exam Room
#Problem There is an exam room with n seats in a single row labeled from 0 to n - 1. When a student enters the room, they must sit in the seat that maximizes the distance to the closest person. If there are multiple such seats, they sit in …
684. Redundant Connection
#Problem In this problem, a tree is an undirected graph that is connected and has no cycles. You are given a graph that started as a tree with n nodes labeled from 1 to n, with one additional edge added. The added edge has two different …
1387. Sort Integers by The Power Value
#Problem The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps: if x is even then x = x / 2 if x is odd then x = 3 * x + 1 For example, the power of x = 3 is 7 because 3 needs 7 …