当前位置:网站首页>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;
}
边栏推荐
- Worthington核糖核酸测定详细攻略
- 实时数仓:美团基于Flink的实时数仓建设实施
- sql 左连接,内连接 的写法「建议收藏」
- Best practices for migration of kingbasees v8.3 to v8.6 of Jincang database (3. Kingbasees migration capability support system)
- JS advanced ES6 ~ es13 new features
- 多传感器融合定位(二)——基于地图的定位
- leetcode 763. Partition Labels 划分字母区间(中等)
- Leetcode64. 最小路径和
- Multi sensor fusion positioning (I) -- 3D laser odometer
- What is a driver signature and how does the driver get a digital signature?
猜你喜欢

Pycharm configuring the running environment

Worthington丨Worthington胰蛋白酶化学性质及相关研究

Equipped with a new generation of ultra safe cellular batteries, Sihao aipao is available from 139900 yuan

Worthington -- Specification of Worthington trypsin inhibitor

ISO 13400(DoIP)标准解读

【C】喝汽水,找单身狗问题

Leetcode60. 排列序列

[TA frost wolf \u may - "hundred people plan"] Figure 3.6 texture compression - inclusion slimming

Jincang database kingbasees client programming interface guide ODBC (2. Overview)

Connection pool - return connection details (Part 2)
随机推荐
Js判断数据类型的4种⽅式
Is the declarative code of compose so concise?
以JSP为视图解析器搭建SSM项目
RHCE first day
【MySQL 8】Generated Invisible Primary Keys(GIPK)
Powercl batch creates and manages virtual switches
Do you know any formal part-time platforms?
双重for循环优化
Type 1-5 components
RHCE the next day
[TA frost wolf \u may - "hundred people plan"] Figure 3.6 texture compression - inclusion slimming
SAP 临时表空间错误处理
【详细超简单】如何使用WebSocket链接
PowerCL 批量创建及管理虚拟交换机
CANoe应用案例之DoIP通信
【C】 Reverse string (two recursive ideas)
数据中台的那些“经验与陷阱”
The failure rate is as high as 80%. How to correctly complete the strategic planning of digital transformation?
Best practices for migration of kingbasees v8.3 to v8.6 of Jincang database (2. Compatibility of kingbasees v8.3 and v8.6)
【C】喝汽水,找单身狗问题