当前位置:网站首页>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;
}
边栏推荐
- Leetcode60. permutation sequence
- Leetcode59. Spiral matrix II
- Worthington丨Worthington胰蛋白酶抑制剂说明书
- What is in word?:^ p
- GhostNets on Heterogeneous Devices via Cheap Operations
- Interpretation of ISO 13400 (doip) standard
- mysql索引失效的常见9种原因详解
- 【C】 Reverse string (two recursive ideas)
- Best practices for migration of kingbasees v8.3 to v8.6 of Jincang database (3. Kingbasees migration capability support system)
- 简述分组密码的加密分组链接模式的工作原理及其特点(密码学移位密码加密解密)
猜你喜欢
【C】 Drink soda and find a single dog
Powercli VMware vCenter deploys conventional new VMS in batch through self built PXE server with one click
Leetcode59. Spiral matrix II
【TA-霜狼_may-《百人计划》】图形3.6 纹理压缩——包体瘦身术
使用Pytorch快速训练网络模型
Worthington RNA determination detailed introduction
PowerCLi 批量添加esxi到vCenter
PowerCL 批量创建及管理虚拟交换机
实时数仓:网易严选基于Flink的实时数仓实践
电商数据模型设计
随机推荐
【TA-霜狼_may-《百人计划》】图形3.6 纹理压缩——包体瘦身术
NAT如何配置地址转换
EN 1935 building hardware. Single axis hinge - CE certification
C语言 n*n矩阵求值及求逆矩阵[通俗易懂]
Multi sensor fusion positioning (I) -- 3D laser odometer
Leetcode59. Spiral matrix II
Machine learning problem notes
Working principle of fastdfs (technical principle)
通配符 SSL/TLS 证书
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
【C】atoi和offsetof的介绍和模拟实现
Jincang database kingbasees client programming interface guide ODBC (2. Overview)
@Transactional 注解使用详解
Jincang database kingbasees client Programming Interface Guide - ODBC feature support constraints
【MySQL 8】Generated Invisible Primary Keys(GIPK)
【C】替换空格,宏实现整数的二进制奇偶位交换
有效供应链管理的八大绩效分析指标(上)
Doip communication of canoe application case
With the help of rpa+lcap, the enterprise treasurer management can be upgraded digitally
台式机dp接口在哪(主机没有dp接口怎么办)