Score Online Exam Responses With Negative Marking and Tied Ranks
Last updated: November 29, 2026
Quick Overview
Given an answer key and each candidate's responses (None for unattempted), compute scores with +3 for correct, -1 for wrong and 0 for skipped, then return candidates ordered by score with standard competition ranks (1, 2, 2, 4).
TCS
November 29, 20260
0
0 solved
Given an answer key and each candidate's responses (None for unattempted), compute scores with +3 for correct, -1 for wrong and 0 for skipped, then return candidates ordered by score with standard competition ranks (1, 2, 2, 4).
TCS iON runs large recruitment and qualifier exams, and an easy online-assessment problem in this style checks whether a fresher can turn a scoring rule into clean code. The grader looks for correct handling of skipped answers, short response lists, and ties in the final rank list.
What the Interviewer Expects
- Apply the three scoring cases exactly, including unattempted questions
- Handle response lists shorter than the answer key
- Sort by score descending with a deterministic tie-break on name
- Assign competition ranks so tied candidates share a rank and the next rank skips
- Run in O(C * Q + C log C)
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you switch to dense ranking (1, 2, 2, 3)?
- What if each question carried its own marks and negative marks?
- How would you break ties by fewer wrong answers before name?
- How would you score ten million candidates streamed from files?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: answer_key (list of options) and responses (dict of candidate to list, where None means skipped). Output: list of (name, score, rank) sorted by score descending, then name. Ties share t...
High-Level Design
Two passes. First, score every candidate by walking the key once. Second, sort and walk the sorted list, carrying the previous rank forward when the score repeats. Keeping scoring and ranking separate...