Tried with .clear() method instead of using new Arraylist<>


#1

from editorial solution,

newArray.add(i);
} else {
newSum = 0;
newArray.clear(); // --------------> tried using this
newArray = new ArrayList<>(); // -> instead of this, getting wrong answer. can anyone please explain, why ??
}