LeetCode Solutions/Algorithm I/Day 10 Recursion - Backtracking/Reverse Linked List.java
<filename>LeetCode Solutions/Algorithm I/Day 10 Recursion - Backtracking/Reverse Linked List.java/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution {
    public ListNode reverseList(ListNode head) {
        ListNode previous = null;
        ListNode current = head ;     
        while(current != null){
            head = current;
            current = current.next;
            head.next = previous;
            previous = head;
        }
        return head;
    }
}