Skip to content

Commit 572eb3e

Browse files
committed
Create README - LeetHub
1 parent c6d23df commit 572eb3e

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

0679-24-game/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<h2><a href="https://leetcode.com/problems/24-game">679. 24 Game</a></h2><h3>Hard</h3><hr><p>You are given an integer array <code>cards</code> of length <code>4</code>. You have four cards, each containing a number in the range <code>[1, 9]</code>. You should arrange the numbers on these cards in a mathematical expression using the operators <code>[&#39;+&#39;, &#39;-&#39;, &#39;*&#39;, &#39;/&#39;]</code> and the parentheses <code>&#39;(&#39;</code> and <code>&#39;)&#39;</code> to get the value 24.</p>
2+
3+
<p>You are restricted with the following rules:</p>
4+
5+
<ul>
6+
<li>The division operator <code>&#39;/&#39;</code> represents real division, not integer division.
7+
8+
<ul>
9+
<li>For example, <code>4 / (1 - 2 / 3) = 4 / (1 / 3) = 12</code>.</li>
10+
</ul>
11+
</li>
12+
<li>Every operation done is between two numbers. In particular, we cannot use <code>&#39;-&#39;</code> as a unary operator.
13+
<ul>
14+
<li>For example, if <code>cards = [1, 1, 1, 1]</code>, the expression <code>&quot;-1 - 1 - 1 - 1&quot;</code> is <strong>not allowed</strong>.</li>
15+
</ul>
16+
</li>
17+
<li>You cannot concatenate numbers together
18+
<ul>
19+
<li>For example, if <code>cards = [1, 2, 1, 2]</code>, the expression <code>&quot;12 + 12&quot;</code> is not valid.</li>
20+
</ul>
21+
</li>
22+
</ul>
23+
24+
<p>Return <code>true</code> if you can get such expression that evaluates to <code>24</code>, and <code>false</code> otherwise.</p>
25+
26+
<p>&nbsp;</p>
27+
<p><strong class="example">Example 1:</strong></p>
28+
29+
<pre>
30+
<strong>Input:</strong> cards = [4,1,8,7]
31+
<strong>Output:</strong> true
32+
<strong>Explanation:</strong> (8-4) * (7-1) = 24
33+
</pre>
34+
35+
<p><strong class="example">Example 2:</strong></p>
36+
37+
<pre>
38+
<strong>Input:</strong> cards = [1,2,1,2]
39+
<strong>Output:</strong> false
40+
</pre>
41+
42+
<p>&nbsp;</p>
43+
<p><strong>Constraints:</strong></p>
44+
45+
<ul>
46+
<li><code>cards.length == 4</code></li>
47+
<li><code>1 &lt;= cards[i] &lt;= 9</code></li>
48+
</ul>

0 commit comments

Comments
 (0)