I am trying to reverse a linked list. This is the code I have come up with:
public static void Reverse(ref Node root) { Node tmp = root; Node n
This performed pretty well on Leetcode.
public ListNode ReverseList(ListNode head) { ListNode previous = null; ListNode current = head; while(current != null) { ListNode nextTemp = current.next; current.next = previous; previous = current; current = nextTemp; } return previous; }