Has to be O(n) and in-place (space complexity of 1). The code below does work, but is there a simpler or better way?
public void invert() { if (this.getH
public void reverse(){ Node middle = head; Node last = head; Node first = null; while(last != null){ middle = last; last = last.next; middle.next = first; first = middle; } head = middle; }