There are N candidates who sign up answer a series of multiple-choice questions. Design a efficient method to evaluate the answer and rank the candidates.
vector <string> Evaluate (const string& answer, const vector<string>& param)
{
// answer - will have the answer for multiple choice question.
// like X X X X X where each X is a capital letter (A-D)
// (e.g) A B A C D
// param will have candidate name followed by his/her answer
// (e.g) param[0] - "Foo A C A C D"
// param[1] - "Bar D D A C B"
// return candidates name with highest % of mark in result[0],
// next highest in result[1] and so on.
}
One approach that I could think of is, tokenize the answer & param and compare it. But I am looking for any better approach. Any suggestions ?
PS: This is not a homework. Came across this question in topcoder