Can anyone tell me approach for the question
You can follow the tutorial. Its always the best way to understand.