Practice · 18 problems
Dynamic Programming
0 of 18 solved on this device
- 032Fibonacci NumberThe Fibonacci sequence is F(0) = 0, F(1) = 1, and F(n) = F(n-1) + F(n-2) for n > 1. Given `n`, return F(n).Easy
- 033Climbing StairsYou are climbing a staircase of `n` steps. Each move you may climb 1 or 2 steps. Return how many distinct ways you can reach the top.Easy
- 034Coin ChangeGiven an array of coin denominations and an integer `amount`, return the fewest coins needed to make up that amount, or -1 if it is impossible. You have an infinite supply of each coin.Medium
- 035Longest Increasing SubsequenceGiven an integer array `nums`, return the length of the longest strictly increasing subsequence. A subsequence need not be contiguous.Medium
- 036House RobberHouses in a row each hold some money. You cannot rob two adjacent houses. Given `nums`, return the maximum amount you can rob tonight.Medium
- 037Word BreakGiven a string `s` and a dictionary `wordDict`, return true if `s` can be segmented into a space-separated sequence of one or more dictionary words. Words may be reused.Medium
- 038Longest Common SubsequenceGiven two strings `text1` and `text2`, return the length of their longest common subsequence, or 0 if there is none.Medium
- 039Edit DistanceGiven two strings `word1` and `word2`, return the minimum number of operations to convert word1 into word2. Permitted operations: insert, delete, replace a character.Hard
- 076Min Cost Climbing StairsYou are given an array `cost` where cost[i] is the price of stepping off step i. After paying you may climb 1 or 2 steps. You may start at index 0 or index 1. Return the minimum cost to reach the top (past the last step).Easy
- 077Unique PathsA robot starts at the top-left of an m x n grid and may only move right or down. Return the number of distinct paths to the bottom-right corner.Medium
- 078Decode WaysA message of digits was encoded with 'A' -> "1" ... 'Z' -> "26". Given a string `s` of digits, return the number of ways to decode it. The answer fits in a 32-bit integer.Medium
- 079Maximum Product SubarrayGiven an integer array `nums`, find the contiguous subarray with the largest product and return that product.Medium
- 080Longest Palindromic SubstringGiven a string `s`, return the longest palindromic substring in it. If several are tied, any one of them is acceptable.Medium
- 119House Robber IIThe houses are arranged in a CIRCLE, so the first and last are adjacent. You cannot rob two adjacent houses. Return the maximum you can rob.Medium
- 120Coin Change IIGiven an array of distinct coin denominations and a target `amount`, return the number of distinct COMBINATIONS that make up that amount. Coins are unlimited. Order does not matter: 1+2 and 2+1 are the same combination.Medium
- 121Partition Equal Subset SumGiven an array `nums` of positive integers, determine whether it can be split into two subsets whose sums are equal.Medium
- 122Target SumGiven an array `nums` and an integer `target`, put a '+' or '-' before each number and concatenate them into an expression. Return how many assignments evaluate to target.Medium
- 123Burst BalloonsBalloons hold coins in `nums`. Bursting balloon i earns nums[i-1] * nums[i] * nums[i+1] coins, where out-of-range neighbors count as 1, and its neighbors then become adjacent. Return the maximum coins obtainable by bursting all balloons.Hard