Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Arranging Coins

XPChallenge Points: 10
levelLevel: Easy

You are given n coins and you want to arrange them to form a staircase.
In this staircase, the 1st row has 1 coin, 2nd row has 2 coins, 3rd row has 3 coins, and so on.

You must place coins row by row, and a row is considered complete only if it contains the exact number of coins required.
If you don’t have enough coins to complete the next row, the staircase stops.

Return the number of fully completed rows.

Example 1:

Input: n = 3

Output: 2

Explanation:

Row 1 → 1 coin Row 2 → 2 coins Total = 3 coins used, both rows are complete.

Example 2:

Input: n = 10

Output: 4

Explanation:

1 + 2 + 3 + 4 = 10 coins. All 4 rows are complete.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result