Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6eeae8d

Browse files
committed
Added README.md file for New 21 Game
1 parent 61fe55a commit 6eeae8d

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

‎867-new-21-game/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<h2><a href="https://leetcode.com/problems/new-21-game">New 21 Game</a></h2> <img src='https://img.shields.io/badge/Difficulty-Medium-orange' alt='Difficulty: Medium' /><hr><p>Alice plays the following game, loosely based on the card game <strong>&quot;21&quot;</strong>.</p>
2+
3+
<p>Alice starts with <code>0</code> points and draws numbers while she has less than <code>k</code> points. During each draw, she gains an integer number of points randomly from the range <code>[1, maxPts]</code>, where <code>maxPts</code> is an integer. Each draw is independent and the outcomes have equal probabilities.</p>
4+
5+
<p>Alice stops drawing numbers when she gets <code>k</code> <strong>or more points</strong>.</p>
6+
7+
<p>Return the probability that Alice has <code>n</code> or fewer points.</p>
8+
9+
<p>Answers within <code>10<sup>-5</sup></code> of the actual answer are considered accepted.</p>
10+
11+
<p>&nbsp;</p>
12+
<p><strong class="example">Example 1:</strong></p>
13+
14+
<pre>
15+
<strong>Input:</strong> n = 10, k = 1, maxPts = 10
16+
<strong>Output:</strong> 1.00000
17+
<strong>Explanation:</strong> Alice gets a single card, then stops.
18+
</pre>
19+
20+
<p><strong class="example">Example 2:</strong></p>
21+
22+
<pre>
23+
<strong>Input:</strong> n = 6, k = 1, maxPts = 10
24+
<strong>Output:</strong> 0.60000
25+
<strong>Explanation:</strong> Alice gets a single card, then stops.
26+
In 6 out of 10 possibilities, she is at or below 6 points.
27+
</pre>
28+
29+
<p><strong class="example">Example 3:</strong></p>
30+
31+
<pre>
32+
<strong>Input:</strong> n = 21, k = 17, maxPts = 10
33+
<strong>Output:</strong> 0.73278
34+
</pre>
35+
36+
<p>&nbsp;</p>
37+
<p><strong>Constraints:</strong></p>
38+
39+
<ul>
40+
<li><code>0 &lt;= k &lt;= n &lt;= 10<sup>4</sup></code></li>
41+
<li><code>1 &lt;= maxPts &lt;= 10<sup>4</sup></code></li>
42+
</ul>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /