hackerrank problem triplets final solution