As posted above, the code doesn’t compile. Please edit your post and either indent the entire code by four spaces, or add three back ticks ``` on a line by themselves both before and after the code.
I made it compile, but then it didn’t give the correct answers for the second test case in the problem, so perhaps I did something wrong.
JAVAC