当前位置:网站首页>Unique paths for leetcode topic resolution
Unique paths for leetcode topic resolution
2022-06-23 08:39:00 【ruochen】
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 reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).
How many possible unique paths are there?
Above is a 3 x 7 grid. How many possible unique paths are there?
Note: m and n will be at most 100.
public int uniquePaths(int m, int n) {
if (m <= 0 || n <= 0) {
return 0;
}
int[][] dp = new int[m][n];
for (int y = 1; y < n; y++) {
dp[0][y] = 1;
}
for (int x = 1; x < m; x++) {
dp[x][0] = 1;
}
for (int y = 1; y < n; y++) {
for (int x = 1; x < m; x++) {
dp[x][y] = dp[x - 1][y] + dp[x][y - 1];
}
}
return dp[m - 1][n - 1];
}边栏推荐
- Vulnhub | DC: 4 | [combat]
- 谈谈 @Autowired 的实现原理
- 实战监听Eureka client的缓存更新
- On the light application platform finclip and the mobile application development platform mpaas
- List interface three sub implementation classes
- Quickly create a consumer cluster
- 5-旋转的小菊-旋转画布和定时器
- 4-绘制椭圆、使用定时器
- Idea true permanent activation method and permanent activation code tutorial
- Pyspark on HPC (Continued): reasonable partition processing and consolidated output of a single file
猜你喜欢

Which one is better for rendering renderings? 2022 latest measured data (IV)

Observer mode

Monitor the cache update of Eureka client

6月《中国数据库行业分析报告》发布!智能风起,列存更生

Talk about the implementation principle of @autowired

Linux Mysql安装

The most commonly used 5-stream ETL mode

Implementation of AVL tree

Qualcomm 9x07 two startup modes

Summary of communication mode and detailed explanation of I2C drive
随机推荐
5-旋转的小菊-旋转画布和定时器
Optimize your gradle module with a clean architecture
单编内核驱动模块
Deep learning ----- different methods to realize vgg16
usb peripheral 驱动 - configfs
Map接口及其子实现类
1-gradients, shadows, and text
On the light application platform finclip and the mobile application development platform mpaas
5、 Project management
Third party payment in the second half: scuffle to symbiosis
Vulnhub | DC: 4 |【實戰】
Which one is better for rendering renderings? 2022 latest measured data (IV)
Summary of communication mode and detailed explanation of I2C drive
自组织映射神经网络(SOM)
Spirit matrix for leetcode topic analysis
How to mine keywords and improve user experience before website construction?
谈谈 @Autowired 的实现原理
kibana 重建index后,如何恢复Visualizations和 Dashboards
训练后的随机森林模型导出和加载
Go 数据类型篇(二)之Go 支持的数据类型概述及布尔类型