63 leetcode - Unique Paths
来源:互联网 发布:中国微软程序员工资 编辑:程序博客网 时间:2024/05/24 03:29
#!/usr/bin/python# -*- coding: utf-8 -*-'''Unique PathsA 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 reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).How many possible unique paths are there?'''class Solution(object): def uniquePaths(self, m, n): """ :type m: int :type n: int :rtype: int """ if m == 0 or n == 0: return 0 dp = [[0] * n for i in range(m)] for i in range(n): dp[0][i] = 1 for i in range(m): dp[i][0] = 1 for row in range(1,m): for col in range(1,n): dp[row][col] = dp[row - 1][col] + dp[row][col - 1] return dp[m-1][n-1]if __name__ == "__main__": s = Solution() print s.uniquePaths(2,2)
0 0
- 63 leetcode - Unique Paths
- leetcode Unique Paths && Unique Paths
- LeetCode 63: Unique Paths II
- [leetcode 63] Unique Paths II
- [LeetCode 63]Unique Paths II
- leetcode || 63、Unique Paths II
- Unique Paths II - LeetCode 63
- Leetcode[63]-Unique Paths II
- Leetcode #63 Unique Paths II
- leetcode 63: Unique Paths II
- Leetcode#63||Unique Paths II
- 【LeetCode】(63)Unique Paths (Medium)
- leetcode 63:Unique Paths II
- Leetcode 63:Unique Paths II
- 【leetcode】【63】Unique Paths II
- 【LeetCode-63】Unique Paths II
- LeetCode 63 - Unique Paths II
- LeetCode 63 Unique Paths II
- 数据结构课程设计 电子投票系统
- String中的null,"",以及String s;等等的区别详解
- EasyUi 时间戳问题
- JavaScript执行环境及作用域
- C-C++面试题2
- 63 leetcode - Unique Paths
- zabbix 临时关闭报警
- Thrift 服务器端的几种工作模式分析
- 最优合并问题
- JavaScript数据转换三——parseInt与parseFloat的区别及判别方式
- [欧拉回路] Codeforces 429E #245 (Div. 1) E. Points and Segments
- 地图定位技术
- 数独问题
- EOJ 1809 询问