Samsung Interview Question for Software Engineer / Developers


Team: SEL
Country: India
Interview Type: In-Person




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

Sorry for Abbreviation.. Its Time Optimization and Space Optimization .. :)

- hprem991 November 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Do we need to move the nodes from existing linked lists to the result list? OR Do we need to create a result list with new nodes with content copied?

Anyway, here is working code. Remove spaces in http word, CareerCup does not allow URLs :(.
h t t p://codepad.org/nn3loNH0

Time Complexity: O(m + n) where m is List1 length and n is List 2 length.

Space Complexity: O(constant) - Nodes from existing lists are moved into result list

Thanks,
Laxmi

- Laxmi Narsimha Rao Oruganti November 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Thanks for share..
Anyway, its kinda easy question i guess........ :)

- hprem991 November 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Linklist Merge2Lists(Linklist s,Linklist t)
{
	Linklist head=NULL,tail=NULL,p1=s,p2=t;
	if((s==NULL)&&(t==NULL)) return NULL;
	if(s==NULL) return t;
	if(t==NULL) return s;

    while((p1!=NULL)&&(p2!=NULL))
	{

		if(p1->data>p2->data)
		{
			if(head==NULL) head=p2;
			if (tail==NULL) tail=p2;
			else tail->next=p2;
			tail=p2;
			p2=p2->next;
            if(head==NULL) head=p2;
		}
		else
		{
			if(head==NULL) head=p1;
			if (tail==NULL) tail=p1;
			else tail->next=p1;
			tail=p1;
			p1=p1->next;
		
		}
	}
    if(p1!=NULL)
	{
		tail->next=p1;

	}
	else
	{
		tail->next=p2;
	}
return head;
}

- Charles December 29, 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