441. Arranging Coins
来源:互联网 发布:惠普spectre 13知乎 编辑:程序博客网 时间:2024/06/04 23:32
441. Arranging Coins
You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins.
Given n, find the total number of full staircase rows that can be formed.
n is a non-negative integer and fits within the range of a 32-bit signed integer.
Example 1:
n = 5The coins can form the following rows:¤¤ ¤¤ ¤Because the 3rd row is incomplete, we return 2.
Example 2:
n = 8The coins can form the following rows:¤¤ ¤¤ ¤ ¤¤ ¤Because the 4th row is incomplete, we return 3.
class Solution {public: int arrangeCoins(int n) { int cnt=0; int i=1; while(n>=i) { cnt++; n=n-i; i++; } return cnt; }};
0 0
- LeetCode 441. Arranging Coins
- 441. Arranging Coins
- 441. Arranging Coins
- 441. Arranging Coins
- 441. Arranging Coins
- LeetCode 441. Arranging Coins
- 441. Arranging Coins
- 441. Arranging Coins
- leetcode 441. Arranging Coins
- 441. Arranging Coins
- Leetcode: 441. Arranging Coins
- LeetCode 441. Arranging Coins
- 441. Arranging Coins
- 【LeetCode】 441. Arranging Coins
- LeetCode 441. Arranging Coins
- [leetcode]441. Arranging Coins
- 441. Arranging Coins
- 441. Arranging Coins*
- iOS:XML文件的解析(SAX解析)
- 跟我一起学C++之name managling与extern “C”
- printf 应用注意和 mosquitto loop简单说明
- WEB容器小谈
- 同一台Windows机器中启动多个Memcached服务
- 441. Arranging Coins
- mpls vpn OSPF配置
- HDU 1521排列组合
- hiho一下 第122周 后缀数组三·重复旋律3
- codeforces - 444c DZY Loves Physics【水】
- Android Studio 运行项目发生instant Run requires启动不了程序
- 机器学习算法与Python实践之(七)逻辑回归(Logistic Regression)
- AJAX基础
- Codeforces550A Two Substrings 暴力