Ooyala Interview Question: from an array of numbers find... | Glassdoor

Interview Question

Software Engineer Interview

from an array of numbers find if the sum of any 2 members

  exists in the array.

Interview Answer

1 Answer


public static boolean doesSumExist(int arr[], int num1, int num2); <--- if this is the function you are trying to solve for,
then you add num1 and num2, iterate the arr comparing each sum to the total. No extra space and runs in O(n^2) time. Isn't super efficient but works

Anonymous on Oct 8, 2015

Add Answers or Comments

To comment on this, Sign In or Sign Up.