Can anyone help with java? Finding common nodes from two linked lists using recursion
- by Dan
I have to write a method that returns a linked list with all the nodes that are common to two linked lists using recursion, without loops.
For example,
first list is 2 - 5 - 7 - 10
second list is 2 - 4 - 8 - 10
the list that would be returned is 2 - 10
I am getting nowhere with this.. What I have been think of was to check each value of the first list with each value of the second list recursively but the second list would then be cut by one node everytime and I cannot compare the next value in the first list with the the second list. I hope this makes sense...
Can anyone help?