https://www.hackerrank.com/challenges/compare-two-linked-lists/problem
package exam.complete;
//https://www.hackerrank.com/challenges/compare-two-linked-lists/problem
import exam.SinglyLinkedListNode;
public class CompareTwoLinkedLists {
static boolean compareLists(SinglyLinkedListNode head1, SinglyLinkedListNode head2) {
if(head1.data != head2.data) return false;
if(head1.next == null && head2.next == null) return true;
if(head1.next == null || head2.next == null) return false;
return compareLists(head1.next, head2.next);
}
}
'Programming > Data Structure' 카테고리의 다른 글
[Hackerrank] FindMergePointofTwoLists (0) | 2020.12.02 |
---|---|
[Hackerrank] DeleteNode (0) | 2020.12.02 |
[Hackerrank] BalancedBrackets (0) | 2020.12.02 |
[Hackerrank] reverseArray (0) | 2020.12.02 |
[Hackerrank] MaximumElement (0) | 2020.12.02 |