This question was asked in hackwithinfy, I could not approach this problem anyhow, can anyone tell me the optimal approach to solve these type of problems and the solution of this specific problem. Here is the question : /predownloaded/ed/e7/ede7594055a5af03da895ed269d4b292e0123a71.jpg /predownloaded/7a/44/7a443d739c061a85cd00c719e1add5be207ee6bf.jpg