摘要: http://www.lintcode.com/zh-cn/problem/unique-paths-ii/在上一题的基础上加入了障碍物。同样可采用递归实现,递推公式不变,但是需要加入对障碍物的判断。下面是实现的代码: 1 #include 2 #include 3 class Solution... 阅读全文
posted @ 2015-07-16 16:41 __brthls 阅读(276) 评论(0) 推荐(0) 编辑
摘要: http://www.lintcode.com/zh-cn/problem/unique-paths/递推公式:f[m][n] = f[m-1][n]+f[m][n-1]可采用DP或者记忆化的递归实现。下面是递归实现的代码: 1 #include 2 class Solution { 3 publ... 阅读全文
posted @ 2015-07-16 16:37 __brthls 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 法1:二分 1 class Solution { 2 public: 3 /** 4 * @param x: An integer 5 * @return: The sqrt of x 6 */ 7 int sqrt(int x) { 8 ... 阅读全文
posted @ 2015-07-16 16:34 __brthls 阅读(171) 评论(0) 推荐(0) 编辑