DP
文章平均质量分 77
sscssz
这个作者很懒,什么都没留下…
展开
-
【34.7】【H】【leetcode】Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. For example, Given [0,1,0,2,1,0,1,3,2,1,2,1]原创 2015-11-28 15:43:26 · 454 阅读 · 0 评论 -
【leetcode】357. Count Numbers with Unique Digits【M】【72】
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x n. Example: Given n = 2, return 91. (The answer should be the total numbers in the range of 0 ≤ x [11,22,33,44,原创 2016-06-21 17:42:23 · 319 阅读 · 0 评论 -
【leetcode】313. Super Ugly Number【M】【14】
Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes of size k. For example, [1, 2, 4, 7, 8, 13,原创 2016-07-06 11:30:23 · 293 阅读 · 0 评论 -
【leetcode】264. Ugly Number II【M】【15】
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 first原创 2016-07-06 11:28:28 · 352 阅读 · 0 评论 -
【leetcode】368. Largest Divisible Subset【M】【65】
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 solution原创 2016-07-04 15:11:46 · 393 阅读 · 0 评论 -
97. Interleaving String【H】【73】
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", ret原创 2016-06-03 16:33:17 · 478 阅读 · 0 评论 -
309. Best Time to Buy and Sell Stock with Cooldown【M】【56】
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, buy one原创 2016-05-30 16:05:13 · 420 阅读 · 0 评论 -
10. Regular Expression Matching【H】【87】【vip】【再来一遍】
Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover the entire input st原创 2016-05-28 16:10:58 · 414 阅读 · 0 评论 -
63. Unique Paths II【M】【30】
Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space is marked as 1 and 0 respectively in the原创 2016-04-14 09:36:29 · 834 阅读 · 0 评论 -
【重来】【vip】5. Longest Palindromic Substring【m】【30】【97】
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. Subscribe to s原创 2016-04-13 13:12:14 · 1254 阅读 · 0 评论 -
213. House Robber II【M】【60】【leetcode】
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. This ti原创 2016-02-26 15:44:04 · 259 阅读 · 0 评论 -
【VIP】322. Coin Change 【M】【53】【动态规划】
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 amount of money原创 2016-03-21 11:01:36 · 542 阅读 · 0 评论 -
120. Triangle【M】【95】【leetcode】
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle [ [2], [3,4],原创 2016-02-24 11:06:45 · 335 阅读 · 0 评论 -
【leetcode题解】[E][52]303. Range Sum Query - Immutable
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Given nums = [-2, 0, 3, -5, 2, -1] sumRange(0, 2) -> 1 sumRange(2, 5) -> -1 sumRan原创 2015-12-23 21:41:35 · 332 阅读 · 0 评论 -
【leetcode题解】【有问题,python没AC,java却过了】【M】【66】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; given n =原创 2015-12-21 22:38:22 · 716 阅读 · 0 评论 -
【leetcode题解】【再来,动态规划】【H】【21.8】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 balloon i you will get num转载 2015-12-21 19:19:52 · 1028 阅读 · 0 评论 -
【leetcode】377. Combination Sum IV【M】
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 = 4 The pos原创 2016-07-28 16:52:45 · 618 阅读 · 0 评论