n students from a class appear in an exam . After the exam a survey is done where they are asked two questions ,
How many students will score less than them ?
How many students will score more than them ?
You have to find out the max number of students who are telling the truth .
int calc(const std::vector<std::pair<int, int>>& students) {}I first approached this problem with a memoization based DP approach but could not break the problem into optimal substructure .
The interviewer did not provide with any limit on n , so I ruled out employing a backtracking solution .
The interviewer was looking for an optimal approach .
Any hints on how this problem can be solved .