How to reverse LinkedList(Node) with O(n) Time and O(1) Space
Information
Time complexity : O(n)
Space complexity : O(1)
input : head node of LinkedList
output : head node of LinkedList
Java Code
public static ListNode reverse(ListNode head) {
ListNode prev = null;
while (head != null) {
ListN...
eunhanlee.hashnode.dev1 min read