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 ...

medium

3083. Existence of a Substring in a String and Its Reverse

Problem Given a string s, find any substring of length 2 which is also present in the reverse of s. A substring is a contigu...

easy

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://le...

medium

3219. Minimum Cost for Cutting Cake II

跟 3218. Minimum Cost for Cutting Cake I 一模一样,只不过 m 和 n 的量级从 20 增加到 10⁵,因此只能用 O(n log n) 贪心解法。 https://leetcode.cn/problems/mi...

hard

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: horizont...

medium hard

2360. Longest Cycle in a Graph

Problem You are given a directed graph of n nodes numbered from 0 to n - 1, where each node has at most one outgoing edge. Th...

hard

2608. Shortest Cycle in a Graph

Problem There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1. The edges in the graph...

hard

3203. Find Minimum Diameter After Merging Two Trees

Problem There exist two undirected trees with n and m nodes, numbered from 0 to n - 1 and from 0 to m - 1, respectively. You ...

hard

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...

medium

2127. Maximum Employees to Be Invited to a Meeting

Problem A company is organizing a meeting and has a list of n employees, waiting to be invited. They have arranged for a larg...

hard

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] ...

medium

685. Redundant Connection II

Problem In this problem, a rooted tree is a directed graph such that, there is exactly one node (the root) for which all othe...

hard

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 sam...

medium

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...

medium

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 starte...

medium

1591. Strange Printer II

Problem There is a strange printer with the following two special requirements: On each turn, the printer will print a solid...

hard

2940. Find Building Where Alice and Bob Can Meet

Problem You are given a 0-indexed array heights of positive integers, where heights[i] represents the height of the iᵗʰ build...

hard

664. Strange Printer

Problem There is a strange printer with the following two special properties: The printer can only print a sequence of the s...

hard

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: ...

medium

1610. Maximum Number of Visible Points

Problem You are given an array points, an integer angle, and your location, where location = [pos_x, pos_y] and points[i] = [...

hard

145. Binary Tree Postorder Traversal

Problem Given the root of a binary tree, return the postorder traversal of its nodes’ values. https://leetcode.com/problems/b...

easy

2872. Maximum Number of K-Divisible Components

Problem There is an undirected tree with n nodes labeled from 0 to n - 1. You are given the integer n and a 2D integer array ...

hard

95. Unique Binary Search Trees II

Problem Given an integer n, return all the structurally unique BST’s (binary search trees), which has exactly n nodes of uniq...

medium

2545. Sort the Students by Their Kth Score

Problem There is a class with m students and n exams. You are given a 0-indexed m x n integer matrix score, where each row re...

medium

96. Unique Binary Search Trees

Problem Given an integer n, return the number of structurally unique BST’s (binary search trees) which has exactly n nodes of...

medium

89. Gray Code

Problem An n-bit gray code sequence is a sequence of 2ⁿ integers where: Every integer is in the inclusive range [0, 2ⁿ - 1],...

medium

72. Edit Distance

Problem Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. You ha...

medium

50. Pow(x, n)

Problem Implement pow(x, n), which calculates x raised to the power n (i.e., xⁿ). https://leetcode.com/problems/powx-n/ Examp...

medium

770. Basic Calculator IV

Problem Given an expression such as expression = "e + 8 - a + 5" and an evaluation map such as {"e":...

hard

227. Basic Calculator II

Problem Given a string s which represents an expression, evaluate this expression and return its value. The integer division ...

medium

224. Basic Calculator

Problem Given a string s representing a valid expression, implement a basic calculator to evaluate it, and return the result ...

hard

2415. Reverse Odd Levels of Binary Tree

Problem Given the root of a perfect binary tree, reverse the node values at each odd level of the tree. For example, suppose...

medium
14567812