leetcode

Leetcode submissions
git clone git://git.laack.co/leetcode.git
Log | Files | Refs | README

arranging-coins.dart (450B)


      1 //Given an integer n return the number of rows it can fill
      2 //assuming each row has one more column than the last (think stairs).
      3 //Time: 314ms Beats: 66.67%
      4 //Memory: 141.4MB Beats: 100%
      5 class Solution {
      6   int arrangeCoins(int n) {
      7       int depth = 1;
      8       while(n > 0){
      9           if(n >= depth){
     10               n -= depth;
     11               depth += 1;
     12           }
     13           else{
     14               break;
     15           }
     16       }
     17       return depth - 1;
     18   }
     19 }