func arrangeCoins(_ n: Int) -> Int {
var k = 1 , sum = 1
while true {
k += 1
sum += k
if sum >= n {
return sum == n ? k : k - 1
}
}
}
网友评论