首页
IT
登录
6mi
u
盘
搜
搜 索
IT
【Leetcode】441. Arranging Coins
【Leetcode】441. Arranging Coins
xiaoxiao
2021-03-25
58
思路:
判断当前行row的剩余总数是否大于row,若是则row++,更新剩余总数为n-row,继续处理下一行。
public class Solution { public int arrangeCoins(int n) { int row = 0, count = 1; while (n > row) { row++; n -= row; } return row; } }
Runtime:55ms
转载请注明原文地址: https://ju.6miu.com/read-38796.html
技术
最新回复
(
0
)