What is the best algorithm or any short way to solve this problem Appy Loves One ,Please explain.?? I got only 30 pts,for brute force solution?? asked 25 Nov '18, 11:32

The editorial for this problem is here (link), which gives a few possibilities. My own approach was: answered 25 Nov '18, 12:01
