全站内容
hard
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] = [x_i, y_i] both denote integral coordinates on the X-Y plane. Initially, you are facing directly east from your …
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 edges of length n - 1, where edges[i] = [aᵢ, bᵢ] indicates that there is an edge between nodes aᵢ and bᵢ in the …
770. Basic Calculator IV
#Problem Given an expression such as expression = "e + 8 - a + 5" and an evaluation map such as {"e": 1} (given in terms of evalvars = ["e"] and evalints = [1]), return a list of tokens representing the simplified expression, such as …
224. Basic Calculator
#Problem Given a string s representing a valid expression, implement a basic calculator to evaluate it, and return the result of the evaluation. Note: You are not allowed to use any built-in function which evaluates strings as mathematical …
3389. Minimum Operations to Make Character Frequencies Equal
#Problem You are given a string s. A string t is called good if all characters of t occur the same number of times. You can perform the following operations any number of times: Delete a character from s. Insert a character in s. Change a …
188. Best Time to Buy and Sell Stock IV
#Problem You are given an integer array prices where prices[i] is the price of a given stock on the iᵗʰ day, and an integer k. Find the maximum profit you can achieve. You may complete at most k transactions: i.e. you may buy at most k …
3213. Construct String with Minimum Cost
#Problem You are given a string target, an array of strings words, and an integer array costs, both arrays of the same length. Imagine an empty string s. You can perform the following operation any number of times (including zero): Choose …
3292. Minimum Number of Valid Strings to Form Target II
3291. Minimum Number of Valid Strings to Form Target I 的进阶版,题目一模一样,但 words 的长度从 5 * 10³ 增加到 5 * 10⁵,target 的长度从 5 * 10³ 增加到 5 * 10⁴。 如果按 problem 3291 中 O(n²) 复杂度的 trie 树 + 动态规划是无法 AC 的,需要用更快的 AC 自动机。
3291. Minimum Number of Valid Strings to Form Target I
#Problem You are given an array of strings words and a string target. A string x is called valid if x is a prefix of any string in words. A prefix of a string is a substring that starts from the beginning of the string and extends to any …
1847. Closest Room
#Problem There is a hotel with n rooms. The rooms are represented by a 2D integer array rooms where rooms[i] = [roomIdᵢ, sizeᵢ] denotes that there is a room with room number roomIdᵢ and size equal to sizeᵢ. Each roomIdᵢ is guaranteed to be …