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
Coding & Algorithms
Software Engineer
Citi
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

0

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
string parsing
modular arithmetic
input validation
payments data quality
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 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 Problems
Sample 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
  1. Normalize (remove spaces, uppercase).
  2. Cheap structural checks first so garbage fails fast.
  3. Rearrange: move the first four characters to the end.
  4. Replace each letter with its number (A=10 ....

Submit Your Answer
Markdown supported

Related Questions