param { number [ ] } array param { number } sum return { number [ ] } function FindNumWithSum ( array , sum ) { if ( ! array || sum < 0 ) { return [ ] ; } let left = 0 ; let right = array . length - 1 ; while ( left < right ) { let total = array [ left ] + array [ right ] ; if ( total === sum ) { return [ array [ left ] , array [ right ] ] ; } else if ( total < sum ) { left ++ ; } else { right -- ; } } return [ ] ; } export { FindNumWithSum } ;