Solved hacker rank