Arranging Coins Problem

Arranging Coins Problem — ExecCode Easy DSA Practice

Solve the Arranging Coins problem on ExecCode. Free online easy DSA practice in Binary Search. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You have n coins and you want to build a staircase with these coins. Your task is to given the integer n, return the number of complete rows of the staircase you will build. The staircase consists of k rows where the i^th row has exactly i coins. The last row of the staircase may be incomplete.

Examples

Input {"n": 5}; Output 2. Input {"n": 8}; Output 3. Input {"n": 1}; Output 1

Constraints

1 <= n <= 2^31 - 1

Practice Arranging Coins free on ExecCode. Browse DSA problems, topic map, and placement guides.