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.
We can simplify your solution even furthur. The following is almost the same but appeared easier to understand to me. Actually the else block is simplified.
Merge two sorted linked lists
You are viewing a single comment's thread. Return to all comments →
We can simplify your solution even furthur. The following is almost the same but appeared easier to understand to me. Actually the else block is simplified.
if((headA==null)&&(headB==null)) return null; if((headA!=null)&&(headB==null)) return headA; if((headA == null)&&(headB!=null)) return headB;