Codility programming puzzles implementation in java