Problem · Math

Integer to String Without Built-ins

Learn this problem
EasyHudson River TradingFULLTIMEPHONE SCREEN

Problem statement

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.

More Hudson River Trading problems

drafts saved locally
public String[] solveIntegerToString(String input) {
    // write your code here
}
input"0\n42\n-17\n2147483647\n-2147483648"
expected["0", "42", "-17", "2147483647", "-2147483648"]
checking account