Same solution in Java not being accepted


#1

Approach works fine for c++, but fails in java. Please heed.