Hacker rank problem