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
Modifying the Node Class
u can override toString method in Node class to input any data
public class Node { public Node node; private int data; Node(int data) { this.data = data; } @Override public String toString() { return this.data+""; }