Romanizer
Reported by candidates from BNP's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
BNP's Romanizer problem hit the assessment circuit in September 2024, and it's a straightforward string transformation task that catches people off guard because it feels too simple. You're converting characters or numeric codes into Roman numerals, or the reverse. The trap isn't the algorithm, it's edge cases and off-by-one errors in your mapping logic. If you blank on the exact conversion rules during the live OA, StealthCoder will feed you the pattern in real time so you don't tank the submission.
Pattern and pitfall
Romanizer is fundamentally a character mapping problem wrapped in string manipulation. You'll either build a conversion from integers to Roman symbols (using pairs like IV, IX, XL, XC, CD, CM) or parse Roman strings back to integers. The trick is the order of operations: you must iterate from largest values down to smallest, or your string builds wrong. Most candidates hardcode arrays and iterate cleanly, but the real gotcha is handling edge cases like zero, leading zeros, or malformed input. During the assessment, having the exact symbol-to-value pairs memorized saves 5 minutes. StealthCoder acts as your safety net if the mapping slips your mind under pressure.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Romanizer cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as integer to roman. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass BNP's OA.
BNP reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Romanizer FAQ
Is this just memorizing Roman numeral rules?+
Mostly yes, but not pure memorization. You need to know the special cases (IV = 4, IX = 9, XL = 40, XC = 90, CD = 400, CM = 900) and iterate in the right order. The code is simple. The edge cases are where you lose points.
What's the most common mistake?+
Iterating from smallest to largest value instead of largest to smallest. You'll produce wrong output like IIII instead of IV. Also, many candidates forget to handle the subtractive pairs and just map single symbols, which fails on numbers like 49 or 999.
How do I prep this in 48 hours?+
Write out the mapping table (1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000 and their symbols). Code the greedy iteration in one direction, then code the reverse. Test on a few examples like 58, 444, 3999. You're done.
Is this harder than it sounds?+
No. The algorithm is a basic greedy loop. The difficulty is just remembering the subtractive notation rules and not making typos. If you've seen it before, you'll code it in 10 minutes. If not, it takes 20-25 including debugging.
Do I need to handle invalid input?+
Almost never in assessments like BNP's. Assume input is valid. If the problem statement mentions validation, you'll see it explicitly. Focus on the conversion logic first.