arrangeCoins = function(n) {
    
    let left = 1;
    let right = n;
    let result = 0;
  
    while(left <= right) {
  
        const mid = Math.floor((right+left)/2);
        const total = (1 + mid) * (mid/2);
        if(n < total) {
            right = mid -1;
        } else {
            left = mid+1;
            result = Math.max(result, mid);
        }
    }
  
    return result;
  }
Binary Search
Time O(log(n)) | Space O(1)
@param {number} n
@return {number}