Time: 60 minutes

The quickest way of thinking when getting the question is to enumerate all the speeds at which bananas can be eaten and find the minimum speed at which all bananas can be eaten.

The enumeration speed range is [1… the largest pile of bananas], because the speed will not be less than 1, and there is no need for the speed to be faster than the largest pile of bananas.

var minEatingSpeed = function(piles, h) {
  // Enumerate all possible speeds to eat bananas and find the smallest one. piles = piles.sort((a,b) => a - b)
  var maxSpeed = piles[piles.length - 1]
  var min = maxSpeed
  for(let i = 1; i <= maxSpeed; i ++) {
    var H = 0    for(let j = 0 ; j < piles.length; j ++) {
      H += Math.ceil(piles[j] / i)
    }
    if(H <= h) {
      min = Math.min(min,i)
    }
  }
  return min
};

It can be thought that [1…maximum speed] is a monotonic interval, which can be solved by bisection.

var minEatingSpeed = function(piles, h) {
  // The minimum speed is to find the lower bound l piles = piles.sort((a,b) => a - b)
  var maxSpeed = piles[piles.length - 1]
  var min = maxSpeed
  // Binary the speed range [1...maxSpeed] var l = 1 , r = maxSpeed
  while(l <= r) {
    var mid = l + Math.floor ((r - l) / 2)
    var H = 0    for(let j = 0 ; j < piles.length ; j ++) {
      H += Math.ceil(piles[j] / mid)
    }
    if ( H <= h ) {
      // If yes, try to see if the speed can be smaller r = mid - 1 } else {
      // Not applicable, increase the speed l = mid + 1 }
  }
  return l
};