Grade a Typed Translation With Typo Tolerance

Last updated: November 29, 2026

Quick Overview

Given a learner's typed answer and a list of accepted translations, return correct for an exact match after normalizing case and punctuation, typo if the answer matches some accepted translation except for at most one word that is within one character edit, and wrong otherwise. Short words of three letters or fewer must match exactly.

Duolingo
Coding & Algorithms
Software Engineer
Duolingo
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given a learner's typed answer and a list of accepted translations, return correct for an exact match after normalizing case and punctuation, typo if the answer matches some accepted translation except for at most one word that is within one character edit, and wrong otherwise. Short words of three letters or fewer must match exactly.

Translation grading is central to Duolingo's lessons, and the product distinguishes a forgivable typo from a real grammar error (an for a is a mistake, not a typo). Onsite, the interviewer looks for a clean one-edit check, a sensible normalization step, and reasoning about why short words are strict.

What the Interviewer Expects
  • Normalizes case, punctuation and whitespace before comparing
  • Implements a linear one-edit-distance check rather than full Levenshtein
  • Applies the short-word rule so grammar words like an and a are not typos
  • Returns correct as soon as any accepted answer matches exactly
  • Tests contractions, punctuation and multiple typos
Key Topics to Cover
String normalization
One edit distance
Two pointers
Product-aware grading rules
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you handle accents, such as accepting cafe for café but flagging it?
  • What if accepted answers number in the thousands for one sentence?
  • How would you highlight the typo to the learner?
  • Why might a typo in a target-language word be graded differently from one in the learner's native language?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Normalize: lowercase, strip punctuation, split on whitespace. Same word count is required for a typo verdict (missing words are real errors). At most one word may differ, the differing word must be lo...

High-Level Design

For each accepted translation: if token lists are equal, return correct immediately. Otherwise, zip tokens, count mismatches, and reject the candidate if a mismatch is on a short word or more than one...


Submit Your Answer
Markdown supported

Related Questions