help make it more generalised.
My code works only for the case of 2 students
Hey!
Try using Binary Search and then solve this question. Try writing a function that uses Binary Search technique, to calculate the answer.
This video can also help. If you face any issues, then feel free to ask them here.
my idea is quite different , i am asking for that idea please don’t suggest me this video .
i have already seen that video.
but i also want to solve it my approach as well.
But I guess your idea is not working for this problem,its working for only a fixed number of students, and that’s the issue with it. Each problem can be solved in a number of ways, but its not always necessary that the approach that initially comes to your mind will work out. Using Binary Search is the correct and easier approach for this problem, that’s why I suggested the video. Also its not always possible that a brute force approach that works for smaller cases can be generalised to bigger cases as well.