Goldman Sachs Interview Question for Software Engineer / Developers


Country: India
Interview Type: In-Person




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

You should see linked list implementation in the linux kernel. This question seems to be parallel to how does iteration over list list_for_each() is implemented.

- rahul.deshmukhpatil May 30, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

CalculateList(A){
count = 0 ;
For each Object o in A{
if( o is type of List){
count = count + CalculateList(o);
}
return count = count +1;
}

- harsh.k.arora May 04, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Alternatively the problem can be viewed as, find length of list. And everyone knows how to find that.

- vps May 04, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

can you explain in more detail your Question

- Anonymous May 04, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Total Number of list present when top level list reference say PARENTLIST is given.

- harsh.k.arora May 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

# <include iostream.h>
do
{
cin>>num;
//proess num here...
while(num!=0);
}

- Anonymous May 13, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

struct LIST {
int data;
LIST * child;
};
int findNumOfList(LIST *l) {
if (l->child == null)
return 0;
return findNumOfList(l->child) + 1;
}

- Anonymous May 15, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public int getListsCount(List list){
int count = 0;
for (int i=0; i <list.size(); i++ ){
if (list.get(i) instanceof Object){
count = count + 1 + getListsCount((List)list.get(i));
}
}
return count;
}

}

- Anonymous May 16, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

not correct, you should define count outside the method itself...otherwise the recursion doesn't take effect...

- athans June 20, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class ParentList {
List myPrivateList= new ArrayList();
public int getNumberOfList(List list)
{

for(Object i: list)
{
if(i instanceof List)
{
count++;
getNumberOfList((List)i);
}
}
return count+1;//for the main list
}

}

- Hitesh Joshi May 30, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

private static int count=0;

have to add this variable as a class variable..
Of course this code is not thread safe

- HItesh May 30, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

A recursive function can be used to traverse through the ParentList and its children and their children and so on...

- Anonymous June 13, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static int findListCount(SpecialList parrent) {
int count = 0;

if (parrent.L == null) {
return 0;
} else {
count = count + findListCount(parrent.L);
count++;
}
return count;
}

- Amar Jaiswal June 15, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

/*A List PARENTLIST which contains primitive type and List L, this List L further can have primitve type and List L and so on.
	 *  Given a Root node calculate how many List it have
	 * */
	public static int listCount(List l){
		int count = 0;
		for (Object object : l) {
			count++;
			if(object instanceof List)
				listCount((List)object);
		}	
		return count;
	}

- Malleswara Dyamappa July 10, 2013 | Flag Reply


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