Skip to content

Commit 7979f25

Browse files
committed
Create README - LeetHub
1 parent a2c9e85 commit 7979f25

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<h2><a href="https://leetcode.com/problems/total-score-of-dungeon-runs">4146. Total Score of Dungeon Runs</a></h2><h3>Medium</h3><hr><p>You are given a <strong>positive</strong> integer <code>hp</code> and two <strong>positive</strong> <strong>1-indexed</strong> integer arrays <code>damage</code> and <code>requirement</code>.</p>
2+
3+
<p>There is a dungeon with <code>n</code> trap rooms numbered from 1 to <code>n</code>. Entering room <code>i</code> reduces your health points by <code>damage[i]</code>. After that reduction, if your remaining health points are <strong>at least</strong> <code>requirement[i]</code>, you earn <strong>1 point </strong>for that room.</p>
4+
5+
<p>Let <code>score(j)</code> be the number of <strong>points</strong> you get if you start with <code>hp</code> health points and enter the rooms <code>j</code>, <code>j + 1</code>, ..., <code>n</code> in this order.</p>
6+
7+
<p>Return the integer <code>score(1) + score(2) + ... + score(n)</code>, the sum of scores over all starting rooms.</p>
8+
9+
<p><strong>Note</strong>: You cannot skip rooms. You can finish your journey even if your health points become non-positive.</p>
10+
11+
<p>&nbsp;</p>
12+
<p><strong class="example">Example 1:</strong></p>
13+
14+
<div class="example-block">
15+
<p><strong>Input:</strong> <span class="example-io">hp = 11, damage = [3,6,7], requirement = [4,2,5]</span></p>
16+
17+
<p><strong>Output:</strong> <span class="example-io">3</span></p>
18+
19+
<p><strong>Explanation:</strong></p>
20+
21+
<p><code>score(1) = 2</code>, <code>score(2) = 1</code>, <code>score(3) = 0</code>. The total score is <code>2 + 1 + 0 = 3</code>.</p>
22+
23+
<p>As an example, <code>score(1) = 2</code> because you get 2 points if you start from room 1.</p>
24+
25+
<ul>
26+
<li>You start with 11 health points.</li>
27+
<li>Enter room 1. Your health points are now <code>11 - 3 = 8</code>. You get 1 point because <code>8 &gt;= 4</code>.</li>
28+
<li>Enter room 2. Your health points are now <code>8 - 6 = 2</code>. You get 1 point because <code>2 &gt;= 2</code>.</li>
29+
<li>Enter room 3. Your health points are now <code>2 - 7 = -5</code>. You do not get any points because <code>-5 &lt; 5</code>.</li>
30+
</ul>
31+
</div>
32+
33+
<p><strong class="example">Example 2:</strong></p>
34+
35+
<div class="example-block">
36+
<p><strong>Input:</strong> <span class="example-io">hp = 2, damage = [10000,1], requirement = [1,1]</span></p>
37+
38+
<p><strong>Output:</strong> <span class="example-io">1</span></p>
39+
40+
<p><strong>Explanation:</strong></p>
41+
42+
<p><code>score(1) = 0</code>, <code>score(2) = 1</code>. The total score is <code>0 + 1 = 1</code>.</p>
43+
44+
<p><code>score(1) = 0</code> because you do not get any points if you start from room 1.</p>
45+
46+
<ul>
47+
<li>You start with 2 health points.</li>
48+
<li>Enter room 1. Your health points are now <code>2 - 10000 = -9998</code>. You do not get any points because <code>-9998 &lt; 1</code>.</li>
49+
<li>Enter room 2. Your health points are now <code>-9998 - 1 = -9999</code>. You do not get any points because <code>-9999 &lt; 1</code>.</li>
50+
</ul>
51+
52+
<p><code>score(2) = 1</code> because you get 1 point if you start from room 2.</p>
53+
54+
<ul>
55+
<li>You start with 2 health points.</li>
56+
<li>Enter room 2. Your health points are now <code>2 - 1 = 1</code>. You get 1 point because <code>1 &gt;= 1</code>.</li>
57+
</ul>
58+
</div>
59+
60+
<p>&nbsp;</p>
61+
<p><strong>Constraints:</strong></p>
62+
63+
<ul>
64+
<li><code>1 &lt;= hp &lt;= 10<sup>9</sup></code></li>
65+
<li><code>1 &lt;= n == damage.length == requirement.length &lt;= 10<sup>5</sup></code></li>
66+
<li><code>1 &lt;= damage[i], requirement[i] &lt;= 10<sup>4</sup></code></li>
67+
</ul>

0 commit comments

Comments
 (0)