当前位置:网站首页>Leetcode 174 Dungeon games (June 23, 2022)
Leetcode 174 Dungeon games (June 23, 2022)
2022-06-24 07:53:00 【ChaoYue_ miku】
Some demons caught the princess (P) And shut her in the lower right corner of the underground city . The underground city is made up of M x N Two dimensional mesh of rooms . Our valiant Knight (K) Originally placed in the room in the upper left corner , He had to go through the dungeon and save the princess by fighting demons .
The knight's initial health points are a positive integer . If his health points drop to 0 Or below , He will die immediately .
Some rooms are guarded by demons , So Knights lose health points when they enter these rooms ( If the value in the room is a negative integer , The knight will lose health points ); The other rooms are either empty ( The value in the room is 0), Or it contains magic balls that increase the health points of knights ( If the value in the room is a positive integer , The knight will increase health points ).
To get to the princess as soon as possible , The knight decided to move only one step to the right or down at a time .
Write a function to calculate the minimum initial health points required to ensure that the knight can save the princess .
for example , Consider the underground city of the following layout , If the knight follows the best path Right -> Right -> Next -> Next , The initial health points of the knight are at least 7.
-2 (K) -3 3
-5 -10 1
10 30 -5 §
explain :
There is no limit on knight health points .
Any room can be a threat to the knight's health points , It may also increase the knight's health points , Including the upper left room where the knight entered and the lower right room where the princess was imprisoned .
source : Power button (LeetCode)
link :https://leetcode.cn/problems/dungeon-game
Copyright belongs to the network . For commercial reprint, please contact the official authority , Non-commercial reprint please indicate the source .
边栏推荐
- What industries and scenarios can the easynvr/easygbs/easycvr platform developed by tsingsee green rhino video be used in?
- LeetCode练习——跳跃游戏、组合求和
- Ke Yi fallible point
- UTC、GMT、CST
- Mysql database recovery case sharing
- 日期、时间库使用备注
- Q & A on cloud development cloudbase hot issues of "Huage youyue phase I"
- Opencvsharp binary image anti color
- Hongmeng OS development III
- LeetCode 515 在每个数行中找最大值[BFS 二叉树] HERODING的LeetCode之路
猜你喜欢
随机推荐
C code writing specification
What is the lifecycle of automated testing?
The startup mode of cloudbase init is \Cloudbase init has hidden dangers
What kind of experience is it when the Institute earns 20000 yuan a month!
Jenkins 太老了 试试它?云原生 CI/CD Tekton
Chapter 3: drawing triangles
Experience of Shenzhou computer
L1-019 who goes first (15 points)
Pyhton crawls to Adu (Li Yifeng) Weibo comments
Thread blocking
Specify IP when calling feign interface
图形技术之坐标转换
基于Distiller的模型压缩工具简介
pair类备注
3-列表简介
Oracle-高级SQL限定查询
Unity 的序列化
Random number remarks
LeetCode练习——跳跃游戏、组合求和
POM configuration provided and test








