Frage im Vorstellungsgespräch bei CloudEndure

parse number from string without using the language parsing technologies

Antworten zu Vorstellungsgespräch

Anonym

28. Juli 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;

Anonym

31. Juli 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