def reverse_linked_list(ls):
    """
    Question 8.2: Reverse a linked list using O(1) space and O(n) time
    """
    last = None
    current = ls

    while current:
        nxt = current.next
        current.next = last
        last = current
        current = nxt

    return last