摘要: Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. 阅读全文
posted @ 2015-05-03 11:33 Mr.do 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 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 p 阅读全文
posted @ 2015-04-27 19:41 Mr.do 阅读(117) 评论(0) 推荐(0) 编辑
摘要: Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example, Given n = 3, your program should return al 阅读全文
posted @ 2015-04-26 13:42 Mr.do 阅读(119) 评论(0) 推荐(0) 编辑
摘要: Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example, Given n = 3, there are a total of 5 unique BST 阅读全文
posted @ 2015-04-23 15:42 Mr.do 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 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 cl 阅读全文
posted @ 2015-04-22 12:55 Mr.do 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 转载出处:http://hawstein.com/posts/dp-novice-to-advanced.html 简介(入门) 什么是动态规划,我们要如何描述它? 动态规划算法通常基于一个递推公式及一个或多个初始状态。 当前子问题的解将由上一次子问题的解推出。使用动态规划来解题只需要多项式时间复杂 阅读全文
posted @ 2015-04-22 10:30 Mr.do 阅读(131) 评论(0) 推荐(0) 编辑
摘要: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the 阅读全文
posted @ 2015-04-20 15:44 Mr.do 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 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, 阅读全文
posted @ 2015-04-13 14:04 Mr.do 阅读(112) 评论(0) 推荐(0) 编辑
摘要: Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Have you thought about this? Here are some good questions 阅读全文
posted @ 2014-12-27 15:41 Mr.do 阅读(93) 评论(0) 推荐(0) 编辑
摘要: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文
posted @ 2014-12-11 14:12 Mr.do 阅读(111) 评论(0) 推荐(0) 编辑