Changing ArrayList to Array gets AC

My friend sent me his code for an easy problem Voters and asked me why is he getting WA in this.
Since I have never used JAVA , I just tried changing the data structures and testing the code (since his logic was correct). Surprisingly, when I changed an ArrayList to a normal array, the code got AC.

His solution: WA
When I changed ArrayList to array: AC

Can anyone explain this?

There is subtle difference between int and Integer.
int x=5,y=5;
x==y returns true
Integer x = new Integer(5);
Integer y = new Integer(5);
x==y returns false
Check this:


Got it. Thank you :slight_smile: