I got this question in Microsoft OA and it took me a lot of time and i couldn't do it. Can anyone please help me with an optimized approach or code for the following question :
Thanks in advance!