Solving hackerrank problems using Scala