We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
My solution in Java. Not sure whether optimal or not
intCompareLists(NodeheadA,NodeheadB){if(headA!=null&&headB!=null){if(headA.data==headB.data)returnCompareLists(headA.next,headB.next);elsereturn0;}elseif(headA==null&&headB==null)// both null at the same timereturn1;elsereturn0;// if any one is null}
Compare two linked lists
You are viewing a single comment's thread. Return to all comments →
My solution in Java. Not sure whether optimal or not