JanaGanaMana
Register
Login
Merging point of two linked lists
జల్సా Jalsa
हम दिल दे चुके सनम ham dil de chuke sanam
Differences between asp and asp.net?
What is a User control ?
Different types of controls available in ASP.NET
ProblemStatement: You have two singly linked lists. Both are merging at one point. You are given two root nodes.
Stack s1 = new Stack();
Stack s2 = new Stack();
node temp = root1;
while(temp!= null) S1.Push(temp);
temp = root2;
while(temp!= null) S2.Push(temp);
while(true)
{
temp = S1.Pop();
if(temp != S2.Pop)
{
break;
}
}
Answer = temp