mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 07:21:40 +08:00
国外版
This commit is contained in:
27
算法题(国外版)/arranging-coins.html
Normal file
27
算法题(国外版)/arranging-coins.html
Normal file
@@ -0,0 +1,27 @@
|
||||
<p>You have <code>n</code> coins and you want to build a staircase with these coins. The staircase consists of <code>k</code> rows where the <code>i<sup>th</sup></code> row has exactly <code>i</code> coins. The last row of the staircase <strong>may be</strong> incomplete.</p>
|
||||
|
||||
<p>Given the integer <code>n</code>, return <em>the number of <strong>complete rows</strong> of the staircase you will build</em>.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
<img alt="" src="https://assets.leetcode.com/uploads/2021/04/09/arrangecoins1-grid.jpg" style="width: 253px; height: 253px;" />
|
||||
<pre>
|
||||
<strong>Input:</strong> n = 5
|
||||
<strong>Output:</strong> 2
|
||||
<strong>Explanation:</strong> Because the 3<sup>rd</sup> row is incomplete, we return 2.
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
<img alt="" src="https://assets.leetcode.com/uploads/2021/04/09/arrangecoins2-grid.jpg" style="width: 333px; height: 333px;" />
|
||||
<pre>
|
||||
<strong>Input:</strong> n = 8
|
||||
<strong>Output:</strong> 3
|
||||
<strong>Explanation:</strong> Because the 4<sup>th</sup> row is incomplete, we return 3.
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= n <= 2<sup>31</sup> - 1</code></li>
|
||||
</ul>
|
Reference in New Issue
Block a user