Domanda di colloquio di Amazon

How do you find if two values in an array sum to a given value? Make it as efficient as possible.

Risposta di colloquio

Anonimo

18 feb 2012

assume two arrays to be A and B of sizes m and n respectively. assume the given sum as S; step 1: sort array B using Quick sort /*Worst case complexity is O(nlogn)*/ step 2: for (i=0 ; i

2