Infosys interview question

The methods I used to execute my assignment.