Match Messy Merchant Descriptors Using Transposition-Aware Edit Distance
Last updated: November 29, 2026
Quick Overview
Card statements show raw descriptors like 'SQ *STARBUKCS'. Implement optimal string alignment distance (insert, delete, substitute, swap adjacent characters) and use it to map a descriptor to the closest known merchant name, returning None when nothing is close enough.
Capital One
November 29, 20260
0
0 solved
Card statements show raw descriptors like 'SQ *STARBUKCS'. Implement optimal string alignment distance (insert, delete, substitute, swap adjacent characters) and use it to map a descriptor to the closest known merchant name, returning None when nothing is close enough.
Capital One cleans merchant names so the app and Eno can show readable transactions and so spend categorization works. This onsite problem tests 2D dynamic programming fluency, an extension of Levenshtein that handles common typing transpositions, and practical judgment about normalization and thresholds.
What the Interviewer Expects
- Write the Levenshtein recurrence and base cases correctly
- Add the adjacent-transposition case with the right indices
- Normalize descriptors before comparing (case, punctuation, processor prefixes)
- Use a length-relative threshold rather than a raw distance
- Discuss the cost of comparing against a large merchant catalog
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 avoid computing the distance against all 50 million merchant names?
- How would you reduce memory to two rows, and why is that harder with transpositions?
- Why is OSA not a true metric, and does that matter here?
- How would you combine this with merchant category code and location signals?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Distance: minimum operations to turn a into b using insert, delete, substitute or swap of two adjacent characters, each costing 1, where no substring is edited twice (the OSA variant).
- Matching: s...
High-Level Design
dp[i][j] is the distance between the first i characters of a and the first j of b. Base cases are dp[i][0] = i and dp[0][j] = j. The transition takes the best of delete, insert and substitute-or...