原文链接: https://leetcode-cn.com/problems/minimum-number-of-refueling-stops 英文原文A car travels from a starting position to a destination which is target miles east of the starting position. There are gas stations along the way. The gas stations are repre…
标签详情
动态规划 分类
原文链接: https://leetcode-cn.com/problems/length-of-longest-fibonacci-subsequence 英文原文A sequence x1, x2, ..., xn is Fibonacci-like if: n >= 3 xi + xi+1 == xi+2 for all i + 2 <= n Given a strictly increasing array arr of positive integers forming a seque…
原文链接: https://leetcode-cn.com/problems/stone-game 英文原文Alice and Bob play a game with piles of stones. There are an even number of piles arranged in a row, and each pile has a positive integer number of stones piles[i]. The objective of the game is to…
原文链接: https://leetcode-cn.com/problems/profitable-schemes 英文原文There is a group of n members, and a list of various crimes they could commit. The ith crime generates a profit[i] and requires group[i] members to participate in it. If a member participa…
原文链接: https://leetcode-cn.com/problems/super-egg-drop 英文原文You are given k identical eggs and you have access to a building with n floors labeled from 1 to n. You know that there exists a floor f where 0 <= f <= n such that any egg dropped at a floor …
原文链接: https://leetcode-cn.com/problems/all-possible-full-binary-trees 英文原文Given an integer n, return a list of all possible full binary trees with n nodes. Each node of each tree in the answer must have Node.val == 0. Each element of the answer is th…
原文链接: https://leetcode-cn.com/problems/bitwise-ors-of-subarrays 英文原文We have an array arr of non-negative integers. For every (contiguous) subarray sub = [arr[i], arr[i + 1], ..., arr[j]] (with i <= j), we take the bitwise OR of all the elements in su…
原文链接: https://leetcode-cn.com/problems/numbers-at-most-n-given-digit-set 英文原文Given an array of digits which is sorted in non-decreasing order. You can write numbers using each digits[i] as many times as we want. For example, if digits = ['1','3','5']…
原文链接: https://leetcode-cn.com/problems/valid-permutations-for-di-sequence 英文原文You are given a string s of length n where s[i] is either: 'D' means decreasing, or 'I' means increasing. A permutation perm of n + 1 integers of all the integers in the ra…
原文链接: https://leetcode-cn.com/problems/cat-and-mouse 英文原文A game on an undirected graph is played by two players, Mouse and Cat, who alternate turns. The graph is given as follows: graph[a] is a list of all nodes b such that ab is an edge of the graph…
原文链接: https://leetcode-cn.com/problems/number-of-music-playlists 英文原文Your music player contains n different songs. You want to listen to goal songs (not necessarily different) during your trip. To avoid boredom, you will create a playlist so that: Ev…
原文链接: https://leetcode-cn.com/problems/flip-string-to-monotone-increasing 英文原文A binary string is monotone increasing if it consists of some number of 0's (possibly none), followed by some number of 1's (also possibly none). You are given a binary str…
原文链接: https://leetcode-cn.com/problems/minimum-falling-path-sum 英文原文Given an n x n array of integers matrix, return the minimum sum of any falling path through matrix. A falling path starts at any element in the first row and chooses the element in t…
原文链接: https://leetcode-cn.com/problems/knight-dialer 英文原文The chess knight has a unique movement, it may move two squares vertically and one square horizontally, or two squares horizontally and one square vertically (with both forming the shape of an …
原文链接: https://leetcode-cn.com/problems/find-the-shortest-superstring 英文原文Given an array of strings words, return the smallest string that contains each string in words as a substring. If there are multiple valid strings of the smallest length, return…
原文链接: https://leetcode-cn.com/problems/tallest-billboard 英文原文You are installing a billboard and want it to have the largest height. The billboard will have two steel supports, one on each side. Each steel support must be an equal height. You are give…
原文链接: https://leetcode-cn.com/problems/delete-columns-to-make-sorted-iii 英文原文You are given an array of n strings strs, all of the same length. We may choose any deletion indices, and we delete all the characters in those indices for each string. For …
原文链接: https://leetcode-cn.com/problems/least-operators-to-express-number 英文原文Given a single positive integer x, we will write an expression of the form x (op1) x (op2) x (op3) x ... where each operator op1, op2, etc. is either addition, subtraction, …
原文链接: https://leetcode-cn.com/problems/binary-tree-cameras 英文原文You are given the root of a binary tree. We install cameras on the tree nodes where each camera at a node can monitor its parent, itself, and its immediate children. Return the minimum nu…
原文链接: https://leetcode-cn.com/problems/odd-even-jump 英文原文You are given an integer array arr. From some starting index, you can make a series of jumps. The (1st, 3rd, 5th, ...) jumps in the series are called odd-numbered jumps, and the (2nd, 4th, 6th,…
原文链接: https://leetcode-cn.com/problems/longest-turbulent-subarray 英文原文Given an integer array arr, return the length of a maximum size turbulent subarray of arr. A subarray is turbulent if the comparison sign flips between each adjacent pair of elemen…
原文链接: https://leetcode-cn.com/problems/number-of-squareful-arrays 英文原文An array is squareful if the sum of every pair of adjacent elements is a perfect square. Given an integer array nums, return the number of permutations of nums that are squareful. …
原文链接: https://leetcode-cn.com/problems/minimum-cost-to-merge-stones 英文原文There are n piles of stones arranged in a row. The ith pile has stones[i] stones. A move consists of merging exactly k consecutive piles into one pile, and the cost of this move …
原文链接: https://leetcode-cn.com/problems/numbers-with-repeated-digits 英文原文Given an integer n, return the number of positive integers in the range [1, n] that have at least one repeated digit. Example 1: Input: n = 20 Output: 1 Explanation: The only pos…
原文链接: https://leetcode-cn.com/problems/best-sightseeing-pair 英文原文You are given an integer array values where values[i] represents the value of the ith sightseeing spot. Two sightseeing spots i and j have a distance j - i between them. The score of a …
原文链接: https://leetcode-cn.com/problems/video-stitching 英文原文You are given a series of video clips from a sporting event that lasted time seconds. These video clips can be overlapping with each other and have varying lengths. Each video clip is describ…
原文链接: https://leetcode-cn.com/problems/divisor-game 英文原文Alice and Bob take turns playing a game, with Alice starting first. Initially, there is a number n on the chalkboard. On each player's turn, that player makes a move consisting of: Choosing any …
原文链接: https://leetcode-cn.com/problems/longest-arithmetic-subsequence 英文原文Given an array nums of integers, return the length of the longest arithmetic subsequence in nums. Recall that a subsequence of an array nums is a list nums[i1], nums[i2], ..., …
原文链接: https://leetcode-cn.com/problems/maximum-sum-of-two-non-overlapping-subarrays 英文原文Given an integer array nums and two integers firstLen and secondLen, return the maximum sum of elements in two non-overlapping subarrays with lengths firstLen and…
原文链接: https://leetcode-cn.com/problems/uncrossed-lines 英文原文You are given two integer arrays nums1 and nums2. We write the integers of nums1 and nums2 (in the order they are given) on two separate horizontal lines. We may draw connecting lines: a stra…