solution2-using-functor

solution-for-question2