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.
I would not say that your solution is simpler to understand. The while statement is overly complex. Better spacing between the operators would help with readability.
"headA != NULL" instead of "headA!=NULL"
At a cursory glance I thought you were accidentally assigning NULL to the pointer until I saw the ! operator.
while(...)headA=headA->next,headB=headB-next;
Although you can use the comma operator to force the statement into one line, a clearer implementation would be:
while(...){headA=headA->next;headB=headB->next;}
However, what I like about your solution is that it does not use recursion.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Compare two linked lists
You are viewing a single comment's thread. Return to all comments →
I would not say that your solution is simpler to understand. The while statement is overly complex. Better spacing between the operators would help with readability.
"headA != NULL" instead of "headA!=NULL"
At a cursory glance I thought you were accidentally assigning NULL to the pointer until I saw the ! operator.
Although you can use the comma operator to force the statement into one line, a clearer implementation would be:
However, what I like about your solution is that it does not use recursion.