Class Solution

java.lang.Object
g0401_0500.s0441_arranging_coins.Solution

public class Solution extends Object
441 - Arranging Coins.<p>Easy</p> <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><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2021/04/09/arrangecoins1-grid.jpg" alt="" /></p> <p><strong>Input:</strong> n = 5</p> <p><strong>Output:</strong> 2</p> <p><strong>Explanation:</strong> Because the 3<sup>rd</sup> row is incomplete, we return 2.</p> <p><strong>Example 2:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2021/04/09/arrangecoins2-grid.jpg" alt="" /></p> <p><strong>Input:</strong> n = 8</p> <p><strong>Output:</strong> 3</p> <p><strong>Explanation:</strong> Because the 4<sup>th</sup> row is incomplete, we return 3.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= n <= 2<sup>31</sup> - 1</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • arrangeCoins

      public int arrangeCoins(int n)