【Leetcode】441. Arranging Coins
思路:
判斷當前行row的剩餘總數是否大於row,若是則row++,更新剩餘總數為n-row,繼續處理下一行。
public class Solution {
public int arrangeCoins(int n) {
int row = 0, count = 1;
while (n > row) {
row++;
n -= row;
}
return row;
}
}
Runtime:55ms
相關文章
- Leetcode 441. Arranging CoinsLeetCode
- Leetcode 解析 (441. Arranging Coins)LeetCode
- LeetCode C++ 441. Arranging Coins【Math/Binary Search】簡單LeetCodeC++
- In this new Buy fifa coins? area
- 【Arranging an Appointment】Unit1 Part3APP
- EverQuest Buy fifa coins site launched
- GameSpot How is Buy fifa coins? developmentGAMdev
- The Buy fifa coins Xbox is saidAI
- POJ-2000 Gold CoinsGo
- [Atcoder DP I]Coins 題解
- Sony Pictures Buy fifa coins ? Digital EntertainmentGitAI
- but youre quickly Fifa 14 ultimate team coins bombardedUI
- HDOJ-1398 Square Coins(母函式)函式
- 「SWTR-4」Collecting Coins 題解
- Where do you go Fifa 14 ultimate team coins afterGo
- Nintendo itself Fifa 14 ultimate team coins isnt bringing
- HDU3519Lucky Coins Sequence(DP+矩陣加速)矩陣
- 杭電ACM hdu 1398 Square Coins 解題報告(母函式)ACM函式
- YT15-HDU-Harry's parents had left him a lot of gold coinsGo
- 【LeetCode】如何學習LeetCode?LeetCode
- LeetcodeLeetCode
- LeetCode in actionLeetCode
- Leetcode AnagramsLeetCode
- Leetcode SortListLeetCode
- Leetcode ReorderListLeetCode
- leetcode SubsetsLeetCode
- Leetcode PermutationsLeetCode
- HDU 母函式簡單題 - 找單詞/Ignatius and the Princess III/Square Coins/Holding Bin-Laden Captive!函式APT
- [LeetCode刷題筆記] 關於LeetCode的前言LeetCode筆記
- 我的 LeetCodeLeetCode
- Leetcode學習LeetCode
- LeetCode 53 JSLeetCodeJS
- LeetCode 50 JSLeetCodeJS
- LeetCode 克隆圖LeetCode
- Leetcode Perfect SquaresLeetCode
- Leetcode Sort ColorsLeetCode
- Leetcode Sort ArrayLeetCode
- 【LeetCode】Jewels and StonesLeetCode