Pregunta de entrevista de CloudEndure

parse number from string without using the language parsing technologies

Respuestas de entrevistas

Anónimo

28 jul 2019

The main idea is to parse each digit of the string (starting from the least significant one) to a number, multiply the result by ten and add the digit. If the char is not a digit return or throw an error;

Anónimo

31 jul 2020

1. After checking for null or blank string, 2. initialize a "sum" variable to 0 3. ...and iterate over all digits from right to left - with each iteration add str[i] * 10^i to sum. 4. done