当前位置: 代码迷 >> 综合 >> Leetcode 441. Arranging Coins
  详细解决方案

Leetcode 441. Arranging Coins

热度:33   发布时间:2023-12-12 21:22:40.0

文章作者:Tyan
博客:noahsnail.com  |  CSDN  |  简书

1. Description

Arranging Coins

2. Solution

class Solution {
public:int arrangeCoins(int n) {int k = 0;while(n > 0) {++k;n -=k;}if(n == 0) {return k;} return k - 1;}
};

Reference

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