JavaScript Program to implement the above approach
function lowerBound ( Ans , target ) { const targetRange = [ - 1 , - 1 ] const leftIdx = extremeInsertionIndex ( Ans , target , true ) if ( leftIdx === Ans . length Ans [ leftIdx ] != target ) return targetRange targetRange [ 0 ] = leftIdx targetRange [ 1 ] = extremeInsertionIndex ( Ans , target , false ) - 1 return targetRange function extremeInsertionIndex ( Ans , target , left ) { let lo = 0 , hi = Ans . length while ( lo < hi ) { const mid = lo + Math . floor ( ( hi - lo ) / 2 ) if ( Ans [ mid ] > target || ( left && target === Ans [ mid ] ) ) hi = mid else lo = mid + 1 } return lo } }