Integer to String Without Built-ins

Reported by candidates from Hudson River Trading's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Hudson River Trading OA. Under 2s to a working solution.
Founder's read

Hudson River Trading reported this one in May 2026, and the catch is right in the statement: convert signed 32-bit integers to decimal strings with no built-in number-to-string helper. It's a string-building problem dressed up as a warm-up. The input is one integer per line, and you return one output line per integer. The traps are 0 and -2147483648. If you blank on the edge cases during the OA, StealthCoder runs invisibly on your desktop as a safety net and hands you a clean solution. Most people won't need it if they read this first.

The problem

Complete the function below. The function receives the full standard input as a single string and returns the exact standard output lines.
Problem Implement itoa: given signed 32-bit integers, convert each integer to its base-10 string representation without using built-in number-to-string conversion helpers.
For each input integer, output the converted decimal string. Negative numbers must include a leading -. The value 0 must return 0.

Function
solveIntegerToString(input: String) → String[]
Complete solveIntegerToString. It has one parameter, String input, containing one signed integer per line. Return the stdout payload as an array of lines, without trailing newline characters.

Examples
Example 1
input = "0\n42\n-17\n2147483647\n-2147483648"
return = ["0","42","-17","2147483647","-2147483648"]
Each integer is converted to its exact decimal string representation.

Constraints
Each value fits in a signed 32-bit integer.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is peeling digits with n % 10 and n / 10, then reversing the collected digits. Zero is the first pitfall. A loop that runs while n > 0 emits nothing for 0, so special-case it and return "0". The second pitfall is -2147483648. If you negate it to make it positive, you overflow a signed 32-bit int in Java or C++. Fix it by widening to a 64-bit long before negating, or by working with negative remainders and flipping each digit with Math.abs. Also remember you must parse the input yourself, since the function receives one big string. Split on newlines, convert each line to a number, then run your itoa. Parsing is where people lose points under pressure. If you freeze on the overflow case live, StealthCoder is the hedge that surfaces the long-widening fix instantly.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Integer to String Without Built-ins 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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Hudson River Trading's OA.

Hudson River Trading reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Integer to String Without Built-ins FAQ

How hard is the Hudson River Trading integer to string question really?+

Easy on the algorithm, but it punishes sloppy edge cases. The digit-peeling loop is five lines. The points are lost on 0, negative numbers, and -2147483648. If you handle those three deliberately, you're done.

What's the trick for -2147483648?+

Its absolute value, 2147483648, doesn't fit in a signed 32-bit int. Cast to a 64-bit long before negating, then peel digits normally. In Python this isn't an issue because integers don't overflow, but the logic should still hold.

Do I need to parse the input myself?+

Yes. The function gets the full standard input as one string with one integer per line. Split on newlines and convert each line to a number. Then apply your own itoa and collect the results into an array of lines with no trailing newline.

How do I build the digit string efficiently?+

Append each digit character to a list or buffer as you peel it from the right, then reverse once at the end. Add the minus sign after reversing, or before it as the last appended character. Avoid repeated string prepends in a loop.

How do I prepare for this in 48 hours?+

Write itoa from scratch three times, once each for positives, negatives, and the min int edge case. Then test with 0, 1, -1, 2147483647, and -2147483648. Also practice splitting raw stdin, since that wrapper is part of this problem.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Hudson River Trading.

OA at Hudson River Trading?
Invisible during screen share
Get it