HackerRank Java Generics problem solution - TheCScience