leetcode

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 58c9262d8e341f8568d194091e92f0045cd4c162
parent c6142948e35eeedb8a01b60ba77e2530454587d8
Author: AndrewLockVI <andrewlaack1@gmail.com>
Date:   Sat, 27 May 2023 12:59:21 -0500

Completed arranging coins using dart

Diffstat:
Aarranging-coins/arranging-coins.dart | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/arranging-coins/arranging-coins.dart b/arranging-coins/arranging-coins.dart @@ -0,0 +1,19 @@ +//Given an integer n return the number of rows it can fill +//assuming each row has one more column than the last (think stairs). +//Time: 314ms Beats: 66.67% +//Memory: 141.4MB Beats: 100% +class Solution { + int arrangeCoins(int n) { + int depth = 1; + while(n > 0){ + if(n >= depth){ + n -= depth; + depth += 1; + } + else{ + break; + } + } + return depth - 1; + } +}