This is my code
public Solution(int n, int p) {
this.n = n;
this.p = p;
graph = new ArrayList<>(n);
for (int i = 0 ;i < n;i++) {
graph.set(i, new ArrayList<>());
}
System.out.println(solve());
}
public ArrayList<ArrayList<Integer>> graph;
I get this exception:
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
The value of n and p are 5, 5