
Dynamic Programming
benbenab
这个作者很懒,什么都没留下…
展开
-
Triangle min path
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.class Solution {public: int minimumTotal(vector > &triangle) {原创 2012-12-08 12:25:03 · 401 阅读 · 0 评论 -
[leetcode] Best Time to Buy and Sell Stock
Best Time to Buy and Sell StockSay you have an array for which the ith element is the price of a given stock on day i.1 If you were only permitted to complete at most one transaction (i原创 2012-12-24 01:15:33 · 407 阅读 · 0 评论 -
Unique Binary Search Trees
Unique Binary Search Trees Given n, how many structurally unique BST's (binary search trees) that store values 1...n?class Solution {public: int numTrees(int n) { // Star原创 2012-12-11 05:35:43 · 426 阅读 · 0 评论 -
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 on a w原创 2012-12-20 03:43:20 · 383 阅读 · 0 评论 -
[leetcode] Distinct Subsequences
Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be n原创 2013-01-05 06:04:29 · 409 阅读 · 0 评论 -
Maximum Subarrary
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] ha原创 2013-10-16 13:18:45 · 637 阅读 · 0 评论