I want to merge two sorted LinkedList from initialized LinkedList (not made from scratch - see code below). After browsing online, every implementation suggested is for LinkedList made from scratch where you define a class Node, etc.. etc. So it doesn't help? Do you have any suggestions on merging two linked lists from my code below?
LinkedList<Integer> list = new LinkedList<>(); LinkedList<Integer> list2 = new LinkedList<>(); list.add(1); list.add(3); list.add(7); list.add(9); list.add(13); list2.add(2); list2.add(40);
--- Update ---
UPDATE - I got to use the method addAll() to add both list to another list and then sort it via Collections.sort() - In another words, it works