leetcode441

public class Solution {
public int ArrangeCoins(int n) {
//convert int to long to prevent integer overflow
long nLong = (long)n;
long st = ;
long ed = nLong;
long mid = ;
while (st <= ed)
{
mid = st + (ed - st) / ; if (mid * (mid + ) <= * nLong)
{
st = mid + ;
}
else
{
ed = mid - ;
}
}
return (int)(st - );
}
}

https://leetcode.com/problems/arranging-coins/#/description

上一篇:一个基于 .NET Core 2.0 开发的简单易用的快速开发框架 - LinFx


下一篇:基于 .NET Core 的简单文件服务器