param { number [ ] } nums param { number } target function SearchRange ( nums , target ) { let left = 0 ; let right = nums . length - 1 ; while ( left < right ) { let mid = Math . floor ( left + ( right - left ) / 2 ) ; if ( nums [ mid ] === target ) { let midLeft = mid ; let midRight = mid ; while ( nums [ midLeft - 1 ] === target ) { midLeft -- ; } while ( nums [ midRight + 1 ] === target ) { midRight ++ ; } return [ midLeft , midRight ] ; } else if ( nums [ mid ] > target ) { right = mid ; } else { left = mid + 1 ; } } return nums [ left ] === target ? [ left , left ] : [ - 1 , - 1 ] ; } export { SearchRange } ;