Tap here to switch tabs
Problem
Submissions

Problem: Arranging Coins

med
30 min
Try to solve the Arranging Coins problem.

Statement

You are given an integer n representing the number of coins.

Arrange the coins into a staircase shape where the iith row contains exactly ii coins. The first row has 11 coin, the second row has 22 coins, and so on.

Return the number of complete rows that can be formed using all the coins.

Note: A row is complete only if it contains exactly the required number of coins.

Constraints:

  • 1≤1 \leq n ≤231−1\leq 2^{31} - 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Arranging Coins

med
30 min
Try to solve the Arranging Coins problem.

Statement

You are given an integer n representing the number of coins.

Arrange the coins into a staircase shape where the iith row contains exactly ii coins. The first row has 11 coin, the second row has 22 coins, and so on.

Return the number of complete rows that can be formed using all the coins.

Note: A row is complete only if it contains exactly the required number of coins.

Constraints:

  • 1≤1 \leq n ≤231−1\leq 2^{31} - 1