当前位置:网站首页>Leetcode62. Different paths
Leetcode62. Different paths
2022-07-29 00:01:00 【Java full stack R & D Alliance】
Title transmission address : https://leetcode.cn/problems/unique-paths/
Operational efficiency :
The code is as follows :
public static int uniquePaths(int m, int n) {
HashMap<String, Integer> map = new HashMap<>();
int i = uniqPathsWithMap(m, n, map);
return i;
}
public static int uniqPathsWithMap(int m, int n, HashMap<String, Integer> map) {
String key = m + ":" + n;
// Use map, Improve operational performance
if (map.containsKey(key)) {
return map.get(key);
}
// Dealing with border situations
if (m == 1 || n == 1) {
return 1;
}
// If you want to walk to (m,n) coordinates , Yes 2 Maybe , The first is from (m-1,n) To (m,n), The first 2 One is from (m,n-1) To (m,n)
int i = uniqPathsWithMap(m - 1, n, map) + uniqPathsWithMap(m, n - 1, map);
map.put(m + ":" + n, i);
return i;
}
边栏推荐
- 【TA-霜狼_may-《百人计划》】图形3.6 纹理压缩——包体瘦身术
- 实时数仓:美团点评Flink的实时数仓应用分享
- EN 12101-8:2011 smoke dampers for smoke and heat control systems - CE certification
- websocket心跳机制(保活机制)
- 通配符 SSL/TLS 证书
- What do you need to bring with you for the NPDP exam? Stationery carrying instructions
- With the help of rpa+lcap, the enterprise treasurer management can be upgraded digitally
- Classification and determination method of Worthington stemxyme
- Leetcode63. 不同路径 II
- Summary of wrong questions of software designers
猜你喜欢

【C】 Drink soda and find a single dog

Worthington核糖核酸测定详细攻略

Explanation of history and chemical properties of Worthington ribonuclease B

【C】atoi和offsetof的介绍和模拟实现

Worthington RNA determination detailed introduction

ZABBIX 5.0 uses its own redis template for monitoring

Apple's official website is being updated to maintain the apple store. Products such as the iPhone 13 / pro of the Bank of China will enjoy a maximum discount of 600 yuan

Leetcode60. 排列序列

Worthington核糖核酸酶B历史和化学性质说明

NAT如何配置地址转换
随机推荐
Where is the DP interface of desktop computer (what if the host has no DP interface)
台式机dp接口在哪(主机没有dp接口怎么办)
Compose 的声明式代码如此简洁?
What is a driver signature and how does the driver get a digital signature?
Leetcode61. 旋转链表
EN 1873屋面用装配附件.塑料单个屋面灯—CE认证
Multi sensor fusion positioning (II) -- map based positioning
【TA-霜狼_may-《百人计划》】美术2.2 模型基础
Do you know any formal part-time platforms?
With the help of rpa+lcap, the enterprise treasurer management can be upgraded digitally
Genomic DNA isolation Worthington ribonuclease A
Machine learning problem notes
[TA frost wolf _may- "hundred people plan"] art 2.2 model basis
【微服务】Nacos集群搭建以及加载文件配置
Leetcode63. 不同路径 II
What do you need to bring with you for the NPDP exam? Stationery carrying instructions
EN 12101-8:2011 smoke dampers for smoke and heat control systems - CE certification
Yolov5 learning notes (I) -- principle overview
多传感器融合定位(一)——3D激光里程计
DoIP测试开发实践