• + 0 comments

    When we reach the part of the code that says "Attach the remaining elements", we have already attached all the elements from 1 list, and only some (if any) of the elements from the other list. For whichever original list that still has elements in it, we simply attach them to the end of the list we've been making. This is done in 1 step, by having the tail element in our new list point to the head element of whichever list still has elements in it.

    HackerRank solutions.