blocks toy blocks. From the top down, the first row has 1 block, the second has 2, the third has 3, and so on: row i has i blocks. Rows are filled in order, and the last one may come up short.
Return how many rows end up completely filled.
Adding rows one at a time takes O(√n); you can do better.blocks=7 → 3
Rows of 1, 2 and 3 use 6 blocks, leaving one block for a fourth row that needs four. Three rows are complete.
blocks=10 → 4
1 + 2 + 3 + 4 = 10, so all four rows are full and nothing is left.
blocks=1 → 1
blocks=7
3
Run checks the first 3 tests in your browser. Submit checks all 57 tests on the server, hidden ones included.