I clearly remember this pattern of question being asked to me second time for now. However, I don't remember the first company very well. This time it was asked again in McAfee hiring challenge and I couldn't come up with a good solution. Anyone up with a optimal solution, please share. I want to go digging in it and see if helps others also, as it is a very frequent interview question type often in good companies.
Anyone up with the solution to this question, let me know in the comments below with the code. Also attach some explanations or comments to your approach :
You can find the link to the question below :[ https://drive.google.com/open?id=1PTy_jd9A7Vokme5DA9eSaqauTT_XtEnh ]