Microsoft Interview Question for Software Engineer in Tests






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

struct Node {
int data;
struct Node *next;
};

int get_int(struct Node *s)
{
int sum=0;
while(s){
sum=sum*10+(s->data);
s=s->next;
}
return sum;
}

- Alok August 02, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Not that easy - incase of carry u need to handle stuff like s->data + s2-> data - the sum has to be checked for carry - so do a %10 and a /10 and add the values accordingly

- Coder August 08, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

@coder Didn't get u

- codex August 18, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

it will not work if we have a link lists like:
11->12->13->NULL
2->3->4->NULL

- Power September 20, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Hey in second problem do we need to compute sum of individual nodes or is this a number ...coz in 1st case we dont need carry

- Anonymous August 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

for the second case length of both link lists need not to be equal. so we have to start from last node and add and keep track of cary.. in case of singly link list this can be done recursively

- anabelle September 02, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

and test cases can be..
two empty linked lists
one empty and onother non empty
link list of different lengths
nos addition resulting in a carry.. suppose if u have 8->2>5 and 1->9->3

- Tweet September 02, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

static int productListImp(List *p, int *val);

int productList(List *p)
{
	int val = 0;
	if(p == NULL)
		return -1;

	return productListImp(p, &val);
}

static int productListImp(List *p, int *val)
{
	int product;
	if(p->next == NULL)
		return p->data;

	product = productListImp(p->next);
	(*val)++;
	product = (p->data) * (pow(10, *val) + product;
	return product
}

- Anonymous September 20, 2011 | 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