Validate IBAN Check Digits Before Releasing a Payment
Last updated: November 29, 2026
Quick Overview
Write a function that takes an IBAN string (possibly with spaces) and returns whether its structure and ISO 13616 mod-97 check digits are valid, without converting the whole string to a big integer.
Citi
November 29, 20260
0
0 solved
Write a function that takes an IBAN string (possibly with spaces) and returns whether its structure and ISO 13616 mod-97 check digits are valid, without converting the whole string to a big integer.
Payment initiation screens in Citi's treasury platforms reject malformed beneficiary accounts before an instruction ever reaches clearing. In an online assessment this checks whether you can turn a written spec into careful string handling and modular arithmetic without overflow tricks.
What the Interviewer Expects
- Normalize input: strip spaces, uppercase
- Check length bounds and the country-letters, check-digits pattern
- Move the first four characters to the end and map letters to 10..35
- Compute mod 97 incrementally, digit by digit
- Return True only when the remainder is 1
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 add per-country length validation (GB is 22, DE is 22, FR is 27)?
- How would you generate the two check digits for a new account number?
- Why does mod 97 catch all single-character substitution errors?
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 is a user-entered IBAN such as GB82 WEST 1234 5698 7654 32. Valid means: 15 to 34 alphanumeric characters after removing spaces, two letters then two digits at the front, and the mod-97 rule h...
High-Level Design
- Normalize (remove spaces, uppercase).
- Cheap structural checks first so garbage fails fast.
- Rearrange: move the first four characters to the end.
- Replace each letter with its number (A=10 ....