Solved medium problem 44.