FastPrepFastPrep
Problem Brief

Integer to String Without Built-ins

FULLTIMEPHONE SCREEN

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 Description

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.

1Example 1

Input
input = "0\n42\n-17\n2147483647\n-2147483648"
Output
["0","42","-17","2147483647","-2147483648"]
Explanation

Each integer is converted to its exact decimal string representation.

Constraints

Limits and guarantees your solution can rely on.

Each value fits in a signed 32-bit integer.

public String[] solveIntegerToString(String input) {
    // write your code here
}
Input

input

"0\n42\n-17\n2147483647\n-2147483648"

Output

["0", "42", "-17", "2147483647", "-2147483648"]

Sign in to submit your solution.