原文链接: https://leetcode-cn.com/problems/word-break-ii 英文原文Given a string s and a dictionary of strings wordDict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences in any order. Note …
标签详情
动态规划 分类
原文链接: https://leetcode-cn.com/problems/maximum-product-subarray 英文原文Given an integer array nums, find a contiguous non-empty subarray within the array that has the largest product, and return the product. It is guaranteed that the answer will fit in …
原文链接: https://leetcode-cn.com/problems/dungeon-game 英文原文The demons had captured the princess and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of m x n rooms laid out in a 2D grid. Our valiant knight was initially posit…
原文链接: https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-iv 英文原文You are given an integer array prices where prices[i] is the price of a given stock on the ith day, and an integer k. Find the maximum profit you can achieve. You may compl…
原文链接: https://leetcode-cn.com/problems/house-robber 英文原文You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent…
原文链接: https://leetcode-cn.com/problems/house-robber-ii 英文原文You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first …
原文链接: https://leetcode-cn.com/problems/maximal-square 英文原文Given an m x n binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. Example 1: Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],[…
原文链接: https://leetcode-cn.com/problems/number-of-digit-one 英文原文Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n. Example 1: Input: n = 13 Output: 6 Example 2: Input: n = 0 Output: 0 …
原文链接: https://leetcode-cn.com/problems/different-ways-to-add-parentheses 英文原文Given a string expression of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. You may return…
原文链接: https://leetcode-cn.com/problems/ugly-number-ii 英文原文An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5. Given an integer n, return the nth ugly number. Example 1: Input: n = 10 Output: 12 Explanation: [1, 2, 3, …
原文链接: https://leetcode-cn.com/problems/perfect-squares 英文原文Given an integer n, return the least number of perfect square numbers that sum to n. A perfect square is an integer that is the square of an integer; in other words, it is the product of some…
原文链接: https://leetcode-cn.com/problems/longest-increasing-subsequence 英文原文Given an integer array nums, return the length of the longest strictly increasing subsequence. A subsequence is a sequence that can be derived from an array by deleting some or…
原文链接: https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-with-cooldown 英文原文You are given an array prices where prices[i] is the price of a given stock on the ith day. Find the maximum profit you can achieve. You may complete as many tra…
原文链接: https://leetcode-cn.com/problems/burst-balloons 英文原文You are given n balloons, indexed from 0 to n - 1. Each balloon is painted with a number on it represented by an array nums. You are asked to burst all the balloons. If you burst the ith ballo…
原文链接: https://leetcode-cn.com/problems/coin-change 英文原文You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you need to m…
原文链接: https://leetcode-cn.com/problems/longest-increasing-path-in-a-matrix 英文原文Given an m x n integers matrix, return the length of the longest increasing path in matrix. From each cell, you can either move in four directions: left, right, up, or dow…
原文链接: https://leetcode-cn.com/problems/house-robber-iii 英文原文The thief has found himself a new place for his thievery again. There is only one entrance to this area, called root. Besides the root, each house has one and only one parent house. After a …
原文链接: https://leetcode-cn.com/problems/counting-bits 英文原文Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1's in the binary representation of i. Example 1: Input: n = 2 Output: [0,1,1…
原文链接: https://leetcode-cn.com/problems/integer-break 英文原文Given an integer n, break it into the sum of k positive integers, where k >= 2, and maximize the product of those integers. Return the maximum product you can get. Example 1: Input: n = 2 Outpu…
原文链接: https://leetcode-cn.com/problems/russian-doll-envelopes 英文原文You are given a 2D array of integers envelopes where envelopes[i] = [wi, hi] represents the width and the height of an envelope. One envelope can fit into another if and only if both t…
原文链接: https://leetcode-cn.com/problems/max-sum-of-rectangle-no-larger-than-k 英文原文Given an m x n matrix matrix and an integer k, return the max sum of a rectangle in the matrix such that its sum is no larger than k. It is guaranteed that there will be…
原文链接: https://leetcode-cn.com/problems/guess-number-higher-or-lower-ii 英文原文We are playing the Guessing Game. The game will work as follows: I pick a number between 1 and n. You guess a number. If you guess the right number, you win the game. If you g…
原文链接: https://leetcode-cn.com/problems/wiggle-subsequence 英文原文A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positi…
原文链接: https://leetcode-cn.com/problems/combination-sum-iv 英文原文Given an array of distinct integers nums and a target integer target, return the number of possible combinations that add up to target. The answer is guaranteed to fit in a 32-bit integer.…
原文链接: https://leetcode-cn.com/problems/is-subsequence 英文原文Given two strings s and t, return true if s is a subsequence of t, or false otherwise. A subsequence of a string is a new string that is formed from the original string by deleting some (can b…
原文链接: https://leetcode-cn.com/problems/rotate-function 英文原文You are given an integer array nums of length n. Assume arrk to be an array obtained by rotating nums by k positions clock-wise. We define the rotation function F on nums as follow: F(k) = 0 …
原文链接: https://leetcode-cn.com/problems/integer-replacement 英文原文Given a positive integer n, you can apply one of the following operations: If n is even, replace n with n / 2. If n is odd, replace n with either n + 1 or n - 1. Return the minimum number…
原文链接: https://leetcode-cn.com/problems/frog-jump 英文原文A frog is crossing a river. The river is divided into some number of units, and at each unit, there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water. …
原文链接: https://leetcode-cn.com/problems/split-array-largest-sum 英文原文Given an array nums which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest…
原文链接: https://leetcode-cn.com/problems/partition-equal-subset-sum 英文原文Given a non-empty array nums containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal. Exampl…