We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f273425 commit 7317a86Copy full SHA for 7317a86
Arranging Coins/Arranging_Coins.cpp
@@ -0,0 +1,26 @@
1
+// Runtime: 8 ms, faster than 56.82% of C++ online submissions for Arranging Coins.
2
+// Memory Usage: 8.3 MB, less than 71.43% of C++ online submissions for Arranging Coins.
3
+
4
+class Solution
5
+{
6
+public:
7
+ int arrangeCoins(int n)
8
+ {
9
+ if (n < 1)
10
11
+ return 0;
12
+ }
13
14
+ long long limit = ceil(sqrt(2.0 * n));
15
16
+ for (long long i = limit; i >= 1; --i)
17
18
+ if ((1 + i) * i <= 2 * static_cast<long long>(n))
19
20
+ return i;
21
22
23
24
+ return 1;
25
26
+};
0 commit comments