Time Complexity and Space Complexity | Function to find a pair in the given array whose sum is equal to z ; Iterate through all the pairs ; Check if the sum of the pair ( a [ i ] , a [ j ] ) is equal to z ; Given Input ; Function Call
function findPair ( a , n , z ) { for ( let i = 0 ; i < n ; i ++ ) for ( let j = 0 ; j < n ; j ++ ) if ( i != j && a [ i ] + a [ j ] == z ) return true ; return false ; } let a = [ 1 , - 2 , 1 , 0 , 5 ] ; let z = 0 ; let n = a . length ; if ( findPair ( a , n , z ) ) document . write ( " " ) ; else document . write ( " " ) ;