Dynamic Programming
文章平均质量分 73
ActiveCoder
An active programmer
展开
-
LeetCode 221. Maximal Square
Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 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 0 0 1 0R原创 2016-04-12 07:24:02 · 206 阅读 · 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 adjacent house原创 2016-04-21 06:37:38 · 259 阅读 · 0 评论 -
LeetCode 62. Unique Paths
Question:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to r原创 2016-04-09 01:09:13 · 304 阅读 · 0 评论 -
Balanced Partition of Array
Given an array which contains random positive integers, divide the array into two parts which has the smallest diff sum, return the smallest diff sum.This problem is solvable using dynamic programmi原创 2016-07-27 12:32:47 · 525 阅读 · 0 评论 -
LeetCode 322. Coin Change
General DP question.#include #include #include using namespace std;/* You are given coins of different denominations and a total amount of money amount. write a function to compute the fe原创 2016-05-02 02:25:40 · 312 阅读 · 0 评论 -
LeetCode 63. Unique Paths II
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 grid.原创 2016-04-09 01:36:28 · 237 阅读 · 0 评论 -
TODO: house robber IIII
TODO: when rob one, the neighbour explored, get the max rob value.原创 2016-07-20 11:27:42 · 253 阅读 · 0 评论 -
Dynamic Programming series
DP is absolutely the best way to category levels of programming..... and it is always the favourite questions being asked by FB or Google.1: Entry Level DP problem. /* A sequence of numbers i原创 2016-07-21 07:08:54 · 292 阅读 · 0 评论 -
LeetCode 70. Climbing Stairs
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?Classical DP problemint cl原创 2016-04-12 00:58:04 · 215 阅读 · 0 评论 -
LeetCode 97. Interleaving String
Given s1, s2, s3, find whether s3 is formed by the interleaving ofs1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc", return原创 2016-04-18 09:20:42 · 309 阅读 · 0 评论 -
LeetCode 72. Edit Distance
Given two words word1 and word2, find the minimum number of steps required to convertword1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:原创 2016-04-16 03:25:36 · 240 阅读 · 0 评论 -
LeetCode 64. Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right whichminimizes the sum of all numbers along its path.Note: You can only move either down or right at原创 2016-04-09 08:15:17 · 225 阅读 · 0 评论 -
Find the Thief (Facebook Interview)
Suppose there is a thief and n rooms.We can only any door to check whether the thief is there or not. during the night, the theif can either move left one room or right one room. Given a sequence of原创 2016-06-15 07:26:35 · 625 阅读 · 0 评论