HackerRank Java 1D Array problem solution - TheCScience