Goldman Sachs Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

B+ trees (treat the numbers as keys to a table in a database).

- Anonymous January 03, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

if the goal is only to find one number in one million unsorted ones, just do linear search

otherwise, use bit array to sort, the find

- Cathy Liu January 15, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You could do one of the following

1. Add all of them to a Hash table and then look up the target number. (O(n) + O(1))
2. Do linear search (if you have to look up only one number) (O(n))
3. Put then in a array, sort them and do binary search on them. (O(NlogN) + O(logN))

- Abdul Malik Mansoor February 01, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Make a binary search tree and traverse.

- cirus February 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I have never tried this, but i think this approach works:

1) Write two java classes which has threads t1, t2 in each of them respectively.
2) t1- will create an expandable array (Vector) which will take 10000 elements a time.
3) t2- will search for the element in the created Vector.
4) when t1 is executing, t2 searches for the element in the created Vector.

This may fasten up things. Let me know if there will be any problem with this approach.

- Nishant February 12, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

This likely won't work very well, for a bunch of reasons:

1) resizing the vector will be costly.
2) if the threads are running on threads in different sockets, the caches are separate. Thread t1 is not really don't anything all that useful as all its work is producing data in the wrong place (cache line misses will be high for t2).
3) t1 could easily examine the entries as it puts them in the vector, probably for little/no overhead.

A good parallel implementation should have threads operating on distinct pieces of the data. For example, t1 could look in the first 500000 integers while t2 looks at the others. The two sets of integers could be stored in two structures by the two threads, using any of the techniques shown above.

- Anonymous May 17, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think it will not work on single processor system.

- Anonymous July 24, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

My mean it will not be faster than a linear search.

- Anonymous July 24, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

very good method, kind of parallel programming.

- Dushbag March 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You can also use a trie, or, if you wanna get fancy, a van emde boas tree.

- memo June 06, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Again, all answers.. no question to ask. If I'm an interviewer, I will minus you guys points because you guys are making ASSumpations. (The poster all need to be clear)

Questions to ask:
Are integers repeated?
Are all integers distinct?
Do you know how many are repeated?
Are integers sequential? (if they are, you don't need stupid fancy btrees and crap)
Are integers in order? (if they are, you don't need stupid fancy btrees and crap)
Are they all random?

Knowing the above will efficienize the method to find it based on the appropriate "algorithm"
It's an overkill to do hashtable and crap if it's sequential.

The question is too easy to be straightforward (oh bsort, bsearch, btree, blah). Interviewer is looking if you are ASSuming. I'm an interviewer, btw, but.. I don't use 1 million.. I use 100 integers and see the questions they try to clarify..that's the real world.

- Anonymous July 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

ok, i will ask

- Anonymous February 28, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

If i am interviewer and see your questions, i would minus your points because several of questions overlap with each others.

- Anonymous June 22, 2012 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Read 1 million integers in a Array, then sort it using Collections.sort, and do a BinarySearch to find a particular integer

- Keane Ka Chamcha January 26, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Extreme intelligent :(

- Anonymous July 24, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

lol

- aa October 19, 2010 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More