diff --git a/java8/src/main/java/com/shekhargulati/ninetynine_problems/_01_lists/P05.java b/java8/src/main/java/com/shekhargulati/ninetynine_problems/_01_lists/P05.java index 130401e..876e1e0 100644 --- a/java8/src/main/java/com/shekhargulati/ninetynine_problems/_01_lists/P05.java +++ b/java8/src/main/java/com/shekhargulati/ninetynine_problems/_01_lists/P05.java @@ -45,5 +45,13 @@ public static List reverse_customStream(ArrayDeque list) { } return StreamSupport.stream(Spliterators.spliteratorUnknownSize(list.descendingIterator(), Spliterator.ORDERED), false).collect(toList()); } + + public static List reverse(LinkedList elements){ + LinkedList reversed = new LinkedList(); + for(T e: elements){ + reversed.addFirst(e); + } + return reversed; + } }