For code problem

can u please provide the code for this problem

Hey @TheSourabh
refer to this : Need code for approach 1