Didnt understand the solution

Here the function has a new Linked List , rather than list 2 .
we could have used list.removefirst in a for loop and add that element in list2 using list2.addlast.
and after that we could have used Collections.sort(list2).

that would take higher complexity
first it will remove elements in m time and add them in another m time
then sort them in (m+n)log(m+n) time
the current solution take m+n time simply

1 Like