File tree 2 files changed +23
-0
lines changed
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 266
266
434|[ Number of Segments in a String] ( ./0434-number-of-segments-in-a-string.js ) |Easy|
267
267
435|[ Non-overlapping Intervals] ( ./0435-non-overlapping-intervals.js ) |Medium|
268
268
437|[ Path Sum III] ( ./0437-path-sum-iii.js ) |Medium|
269
+ 441|[ Arranging Coins] ( ./0441-arranging-coins.js ) |Easy|
269
270
442|[ Find All Duplicates in an Array] ( ./0442-find-all-duplicates-in-an-array.js ) |Medium|
270
271
443|[ String Compression] ( ./0443-string-compression.js ) |Medium|
271
272
448|[ Find All Numbers Disappeared in an Array] ( ./0448-find-all-numbers-disappeared-in-an-array.js ) |Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 441. Arranging Coins
3
+ * https://leetcode.com/problems/arranging-coins/
4
+ * Difficulty: Easy
5
+ *
6
+ * You have n coins and you want to build a staircase with these coins. The staircase consists
7
+ * of k rows where the ith row has exactly i coins. The last row of the staircase may be incomplete.
8
+ *
9
+ * Given the integer n, return the number of complete rows of the staircase you will build.
10
+ */
11
+
12
+ /**
13
+ * @param {number } n
14
+ * @return {number }
15
+ */
16
+ var arrangeCoins = function ( n ) {
17
+ let count = 0 ;
18
+ for ( ; count <= n ; count ++ ) {
19
+ n -= count ;
20
+ }
21
+ return count - 1 ;
22
+ } ;
You can’t perform that action at this time.
0 commit comments