Solved medium problem 43.