HackerRank Java Arraylist problem solution - TheCScience