Goldman Sachs
Work in HR? Unlock Free Profile

Goldman Sachs Summer Analyst Interview Question

"Write a function that accepts two arrays and returns one array with the elements in a but not in b?"
Add Tags [?]

Part of a Summer Analyst Interview Review - one of 1,564 Goldman Sachs Interview Reviews

Answers & Comments

of 0
Make a new array c
Make a bool duplicate = false
Loop through a
For each element in a, loop through b
if a=b, change duplicate to true,
Now when you are done with your inner b loop
perform an if condition check on the bool
If duplicate = false, then current element in a you are looping over into array c
- Anonymous on Nov 8, 2013
of 0
^ for the above solution: this new array c should be initiliazed to have the same size as a.
In the case there are elements in a that are also in b, c would have indices where there is no element in a particular index
- Anonymous on Nov 8, 2013

To comment on this question, Sign In with Facebook or Sign Up

Tags are like keywords that help categorize interview questions that have something in common.