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.
Input: n = 3
Output: 2
Explanation:
Row 1 → 1 coin Row 2 → 2 coins Total = 3 coins used, both rows are complete.
Input: n = 10
Output: 4
Explanation:
1 + 2 + 3 + 4 = 10 coins. All 4 rows are complete.
Accepted:
Submission: