Solved problem 422 base case