Public · Protected · Private
Merging point of two linked lists
Type: Public  |  Created: 2008-08-09  |  Frozen: Yes
« Previous Public Blog Next Public Blog »
Comments
  • ProblemStatement: You have two singly linked lists. Both are merging at one point. You are given two root nodes.
    2008-08-09 01:39
  • 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
    2008-08-09 01:44
This blog is frozen. No new comments or edits allowed.