首页 > 代码库 > LeetCode "Arranging Coins"

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;    }};

LeetCode "Arranging Coins"