I tried to solve this question using Binary Search. And I am not able to understand why one of my solutions is giving me the wrong answer while other got accepted.
Problem Link
Submission 1 (Wrong)
Submission 2 (Accepted)
Submission 3 (Accepted)
The person is also not that much good at maths but wants to improve his mathematical skills in 1 to 2 years practicing the book. If you have multiple books in mind for please list it in the order of preference i.e which should be studied first. Thanks in advance !! :)