
动态规划
文章平均质量分 62
帘外雨
学生一枚
展开
-
LeetCode 446. Arithmetic Slices II - Subsequence
**问题描述:** A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arith转载 2017-06-28 21:52:07 · 274 阅读 · 0 评论 -
Leetcode 97. Interleaving String
问题描述 Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc", r原创 2017-07-12 16:11:09 · 289 阅读 · 0 评论 -
Leetcode 115. Distinct Subsequences
问题描述 Given a string S and a string T, count the number of distinct subsequences of S which equals T.A subsequence of a string is a new string which is formed from the original string by deleti原创 2017-07-12 16:59:14 · 226 阅读 · 0 评论 -
Leetcode 312. Burst Balloons
问题描述 Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst ba原创 2017-07-03 16:53:00 · 215 阅读 · 0 评论 -
Leetcode 304. Range Sum Query 2D - Immutable
问题描述 Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).The above rectangle (with the原创 2017-07-03 21:36:46 · 186 阅读 · 0 评论 -
Leetcode 300. Longest Increasing Subsequence
问题描述 Given an unsorted array of integers, find the length of longest increasing subsequence.For example,Given [10, 9, 2, 5, 3, 7, 101, 18],The longest increasing subsequence is [2, 3, 7, 10原创 2017-07-03 21:59:01 · 190 阅读 · 0 评论 -
Leetcode 279. Perfect Squares
问题描述 Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because 12 = 4 + 4 + 4; give原创 2017-07-04 11:07:25 · 201 阅读 · 0 评论 -
leetcode 629 K Inverse Pairs Array
问题描述: Given two integers n and k, find how many different arrays consist of numbers from 1 to n such that there are exactly k inverse pairs. We define an inverse pair as following:For ith an原创 2017-06-26 20:27:02 · 1424 阅读 · 0 评论 -
LeetCode 552. Student Attendance Record II
问题描述: Given a positive integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, return it after mod 109原创 2017-06-26 21:17:46 · 427 阅读 · 0 评论 -
Leetcode 517. Super Washing Machines
问题描述: You have n super washing machines on a line. Initially, each washing machine has some dresses or is empty. For each move, you could choose any m (1 ≤ m ≤ n) washing machines, and pass on原创 2017-06-28 10:17:54 · 721 阅读 · 0 评论 -
Leetcode 514. Freedom Trail
问题描述: In the video game Fallout 4, the quest “Road to Freedom” requires players to reach a metal dial called the “Freedom Trail Ring”, and use the dial to spell a specific keyword in order to原创 2017-06-28 11:10:56 · 915 阅读 · 1 评论 -
Leetcode 472. Concatenated Words
问题描述: Given a list of words (without duplicates), please write a program that returns all concatenated words in the given list of words.A concatenated word is defined as a string that is compr原创 2017-06-28 14:53:13 · 373 阅读 · 0 评论 -
Leetcode 221. Maximal Square
问题描述 Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area.For example, given the following matrix:1 0 1 0 01 0 1 1 11 1 1 1 11原创 2017-07-08 19:11:12 · 188 阅读 · 0 评论 -
Leetcode 264. Ugly Number II
问题描述 Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the原创 2017-07-10 10:22:10 · 210 阅读 · 0 评论 -
LeetCode:647. Palindromic Substrings
Given a string, your task is to count how many palindromic substrings in this string.The substrings with different start indexes or end indexes are counted as different substrings even they consist of原创 2017-09-07 19:12:04 · 245 阅读 · 0 评论 -
Leetcode 321. Create Maximum Number
问题描述: Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. The relative order of the digi转载 2017-07-03 15:36:34 · 505 阅读 · 0 评论 -
Leetcode 87. Scramble String
问题描述 Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = "great": great /原创 2017-07-12 10:57:44 · 281 阅读 · 0 评论 -
Leetcode 198. 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 ad原创 2017-07-10 15:03:24 · 170 阅读 · 0 评论 -
Leetcode 213. House Robber II
问题描述 Note: This is an extension of House Robber.After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. T原创 2017-07-10 16:00:25 · 245 阅读 · 0 评论 -
Leetcode 403. Frog Jump
问题描述 A frog is crossing a river. The river is divided into x 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.Given a原创 2017-06-30 09:51:26 · 400 阅读 · 0 评论 -
Leetcode 377. Combination Sum IV
问题描述 Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.Example:nums = [1, 2, 3]target = 4T原创 2017-06-30 10:50:51 · 219 阅读 · 0 评论 -
Leetcode 376. Wiggle Subsequence
问题描述 A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may b原创 2017-06-30 12:00:10 · 203 阅读 · 0 评论 -
Leetcode 368. Largest Divisible Subset
问题描述 Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj % Si = 0.If there are multiple so原创 2017-06-30 14:53:20 · 185 阅读 · 0 评论 -
Leetcode 357. Count Numbers with Unique Digits
问题描述 Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Example:Given n = 2, return 91. (The answer should be the total numbers in the range of 0 ≤原创 2017-06-30 15:59:54 · 190 阅读 · 0 评论 -
Leetcode 188. Best Time to Buy and Sell Stock IV
问题描述 Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most k transactions.Note:You may转载 2017-07-10 19:57:30 · 290 阅读 · 0 评论 -
Leetcode 174. Dungeon Game
问题描述 table.dungeon, .dungeon th, .dungeon td { border:3px solid black;} .dungeon th, .dungeon td { text-align: center; height: 70px; width: 70px;}The demons had captured the p转载 2017-07-10 22:20:49 · 239 阅读 · 0 评论 -
Leetcode 354. Russian Doll Envelopes
问题描述 You have a number of envelopes with widths and heights given as a pair of integers (w, h). One envelope can fit into another if and only if both the width and height of one envelope is gre原创 2017-06-30 17:09:26 · 341 阅读 · 0 评论 -
Leetcode 322. Coin Change
问题描述 You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amo原创 2017-06-30 21:45:01 · 194 阅读 · 0 评论 -
Leetcode 338 Counting Bits
问题描述 Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array.Example:For n原创 2017-06-30 20:42:01 · 258 阅读 · 0 评论 -
Leetcode 72. Edit Distance
问题描述 Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted o原创 2017-07-11 22:05:31 · 234 阅读 · 0 评论 -
Leetcode 32. Longest Valid Parentheses
问题描述 Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "原创 2017-07-11 16:36:51 · 243 阅读 · 0 评论 -
Leetcode 309. Best Time to Buy and Sell Stock with Cooldown
问题描述 Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like(ie原创 2017-07-03 21:07:44 · 177 阅读 · 0 评论