Approach to solve the problem