原文链接: https://leetcode-cn.com/problems/minimum-score-triangulation-of-polygon 英文原文You have a convex n-sided polygon where each vertex has an integer value. You are given an integer array values where values[i] is the value of the ith vertex (i.e., cl…
标签详情
动态规划 分类
原文链接: https://leetcode-cn.com/problems/as-far-from-land-as-possible 英文原文Given an n x n grid containing only values 0 and 1, where 0 represents water and 1 represents land, find a water cell such that its distance to the nearest land cell is maximized…
原文链接: https://leetcode-cn.com/problems/partition-array-for-maximum-sum 英文原文Given an integer array arr, partition the array into (contiguous) subarrays of length at most k. After partitioning, each subarray has their values changed to become the maxim…
原文链接: https://leetcode-cn.com/problems/longest-string-chain 英文原文You are given an array of words where each word consists of lowercase English letters. wordA is a predecessor of wordB if and only if we can insert exactly one letter anywhere in wordA w…
原文链接: https://leetcode-cn.com/problems/last-stone-weight-ii 英文原文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 any two stones and smash them tog…
原文链接: https://leetcode-cn.com/problems/shortest-common-supersequence 英文原文Given two strings str1 and str2, return the shortest string that has both str1 and str2 as subsequences. If there are multiple valid strings, return any of them. A string s is a…
原文链接: https://leetcode-cn.com/problems/filling-bookcase-shelves 英文原文You are given an array books where books[i] = [thicknessi, heighti] indicates the thickness and height of the ith book. You are also given an integer shelfWidth. We want to place the…
原文链接: https://leetcode-cn.com/problems/smallest-sufficient-team 英文原文In a project, you have a list of required skills req_skills, and a list of people. The ith person people[i] contains a list of skills that the person has. Consider a sufficient team:…
原文链接: https://leetcode-cn.com/problems/minimum-falling-path-sum-ii 英文原文Given an n x n integer matrix grid, return the minimum sum of a falling path with non-zero shifts. A falling path with non-zero shifts is a choice of exactly one element from each…
原文链接: https://leetcode-cn.com/problems/minimum-cost-tree-from-leaf-values 英文原文Given an array arr of positive integers, consider all binary trees such that: Each node has either 0 or 2 children; The values of arr correspond to the values of each leaf …
原文链接: https://leetcode-cn.com/problems/number-of-paths-with-max-score 英文原文You are given a square board of characters. You can move on the board starting at the bottom right square marked with the character 'S'. You need to reach the top left square m…
原文链接: https://leetcode-cn.com/problems/n-th-tribonacci-number 英文原文The Tribonacci sequence Tn is defined as follows: T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0. Given n, return the value of Tn. Example 1: Input: n = 4 Output: 4 Exp…
原文链接: https://leetcode-cn.com/problems/largest-1-bordered-square 英文原文Given a 2D grid of 0s and 1s, return the number of elements in the largest square subgrid that has all 1s on its border, or 0 if such a subgrid doesn't exist in the grid. Example 1:…
原文链接: https://leetcode-cn.com/problems/stone-game-ii 英文原文Alice and Bob continue their games with piles of stones. There are a number of piles arranged in a row, and each pile has a positive integer number of stones piles[i]. The objective of the game…
原文链接: https://leetcode-cn.com/problems/distinct-echo-substrings 英文原文Return the number of distinct non-empty substrings of text that can be written as the concatenation of some string with itself (i.e. it can be written as a + a where a is some string…
原文链接: https://leetcode-cn.com/problems/longest-common-subsequence 英文原文Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0. A subsequence of a string is a new string gen…
原文链接: https://leetcode-cn.com/problems/longest-chunked-palindrome-decomposition 英文原文You are given a string text. You should split it to k substrings (subtext1, subtext2, ..., subtextk) such that: subtexti is a non-empty string. The concatenation of a…
原文链接: https://leetcode-cn.com/problems/number-of-dice-rolls-with-target-sum 英文原文You have d dice and each die has f faces numbered 1, 2, ..., f. You are given three integers d, f, and target. Return the number of possible ways (out of fd total ways) m…
原文链接: https://leetcode-cn.com/problems/largest-multiple-of-three 英文原文Given an array of digits digits, return the largest multiple of three that can be formed by concatenating some of the given digits in any order. If there is no answer return an empt…
原文链接: https://leetcode-cn.com/problems/constrained-subsequence-sum 英文原文Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence, nums…
原文链接: https://leetcode-cn.com/problems/maximum-subarray-sum-with-one-deletion 英文原文Given an array of integers, return the maximum sum for a non-empty subarray (contiguous elements) with at most one element deletion. In other words, you want to choose …
原文链接: https://leetcode-cn.com/problems/make-array-strictly-increasing 英文原文Given two integer arrays arr1 and arr2, return the minimum number of operations (possibly zero) needed to make arr1 strictly increasing. In one operation, you can choose two in…
原文链接: https://leetcode-cn.com/problems/kth-ancestor-of-a-tree-node 英文原文You are given a tree with n nodes numbered from 0 to n - 1 in the form of a parent array parent where parent[i] is the parent of ith node. The root of the tree is node 0. Find the…
原文链接: https://leetcode-cn.com/problems/k-concatenation-maximum-sum 英文原文Given an integer array arr and an integer k, modify the array by repeating it k times. For example, if arr = [1, 2] and k = 3 then the modified array will be [1, 2, 1, 2, 1, 2]. R…
原文链接: https://leetcode-cn.com/problems/count-ways-to-build-rooms-in-an-ant-colony 英文原文You are an ant tasked with adding n new rooms numbered 0 to n-1 to your colony. You are given the expansion plan as a 0-indexed integer array of length n, prevRoom,…
原文链接: https://leetcode-cn.com/problems/where-will-the-ball-fall 英文原文You have a 2-D grid of size m x n representing a box, and you have n balls. The box is open on the top and bottom sides. Each cell in the box has a diagonal board spanning two corner…
原文链接: https://leetcode-cn.com/problems/longest-arithmetic-subsequence-of-given-difference 英文原文Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that the diff…
原文链接: https://leetcode-cn.com/problems/dice-roll-simulation 英文原文A die simulator generates a random number from 1 to 6 for each roll. You introduced a constraint to the generator such that it cannot roll the number i more than rollMax[i] (1-indexed) c…
原文链接: https://leetcode-cn.com/problems/maximum-profit-in-job-scheduling 英文原文We have n jobs, where every job is scheduled to be done from startTime[i] to endTime[i], obtaining a profit of profit[i]. You're given the startTime, endTime and profit array…
原文链接: https://leetcode-cn.com/problems/tiling-a-rectangle-with-the-fewest-squares 英文原文Given a rectangle of size n x m, return the minimum number of integer-sided squares that tile the rectangle. Example 1: Input: n = 2, m = 3 Output: 3 Explanation: 3…