LeetCode "Arranging Coins"

A simple math.. take care of data overflow though.

class Solution {
public:
    int arrangeCoins(int n) {
        if(n < 0) return -1;
        return sqrt((long long)2 * n + 0.25) - 0.5;
    }
};
原文地址:https://www.cnblogs.com/tonix/p/6015090.html