当前位置:网站首页>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 .
边栏推荐
- Chapitre 2: dessiner une fenêtre
- Wechat cloud hosting hot issues Q & A
- 慕思股份在深交所上市:毛利率持续下滑,2022年一季度营销失利
- Chrono usage notes
- any类备注
- 免费ICP域名备案查接口
- 开放合作,共赢未来 | 福昕鲲鹏加入金兰组织
- Moonwell Artemis现已上线Moonbeam Network
- LeetCode 515 在每个数行中找最大值[BFS 二叉树] HERODING的LeetCode之路
- Teach you how to use the reflect package to parse the structure of go - step 2: structure member traversal
猜你喜欢

Introduction of model compression tool based on distiller

【Django中运行scrapy框架,并将数据存入数据库】

RDD的执行原理

语料库数据处理个案实例(读取多个文本文件、读取一个文件夹下面指定的多个文件、解码错误、读取多个子文件夹文本、多个文件批量改名)

免费ICP域名备案查接口

屏幕截图推荐—Snipaste

【NILM】非入侵式负荷分解模块nilmtk安装教程

Cold thinking on the hot track: multiplier effect is the fundamental requirement of East West calculation

爬虫基础B1——Scrapy(B站学习笔记)

Hongmeng OS development III
随机推荐
Pyhton crawls to Adu (Li Yifeng) Weibo comments
鸿蒙开发四
What industries and scenarios can the easynvr/easygbs/easycvr platform developed by tsingsee green rhino video be used in?
Ke Yi fallible point
本地备份和还原 SQL Server 数据库
Any remarks
L1-019 who goes first (15 points)
Detailed explanation of PHP data serialization test example
.jar中没有主清单属性
atguigu----15-内置指令
Phonics
云开发谁是卧底小程序源码
Jenkins 太老了 试试它?云原生 CI/CD Tekton
Domain environment importing Tencent cloud considerations
热赛道上的冷思考:乘数效应才是东数西算的根本要求
Error "computing failed in `stat\u summary\u hex() `"
保留一位小数和保留两位小数
SVN实测常用操作-记录操作大全
Alibaba cloud full link data governance
《canvas》之第4章 线条操作