I applied brute force here and getting tle so what would be a better approach?
@tharunnayak14 try thinking of binary search