dynamic-programming
喜欢恋着风
这个作者很懒,什么都没留下…
展开
-
动态规划----各种最长序列
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [4,-1,2,1] has the原创 2017-06-19 14:56:26 · 194 阅读 · 0 评论 -
375. Guess Number Higher or Lower II
We are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I picked.Every time you guess wrong, I’ll tell you whether the number I picked is highe原创 2017-06-20 11:14:44 · 188 阅读 · 0 评论 -
494. Target Sum
You are given a list of non-negative integers, a1, a2, …, an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol.Find out how many w原创 2017-06-20 11:18:55 · 175 阅读 · 0 评论 -
152. Maximum Product Subarray dynamic programming
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4], the contiguous subarray [2,3] has the largest produ原创 2017-06-20 11:11:36 · 229 阅读 · 0 评论 -
375. Guess Number Higher or Lower II dynamic programming
We are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I picked.Every time you guess wrong, I’ll tell you whether the number I picked is highe原创 2017-06-19 15:44:27 · 163 阅读 · 0 评论 -
70. Climbing Stairs dynamic programming
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a positive inte原创 2017-06-19 15:20:33 · 201 阅读 · 0 评论 -
303. Range Sum Query - Immutable dynamic programming
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 sumRange(0, 5原创 2017-06-19 15:14:18 · 191 阅读 · 0 评论 -
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 adjacent houses原创 2017-06-19 14:57:09 · 156 阅读 · 0 评论 -
121. Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), desi原创 2017-06-19 14:48:40 · 174 阅读 · 0 评论