|
|
|
|
|
by google234123
1550 days ago
|
|
You are right it’s not the best, but I think it’s a fine starting/warm up question for a C or C++ interview. Atoi can make for a fun discussion just because error handling is so bad in the standard c version. The most common output value is also the same as the return value for an error: 0. I think some versions set the Errno global on failure, can’t recall. There is definitely room for 2x to 3x performance improvements on the implementation you linked by changing the main loop to not have each iteration depend upon the result of the previous iteration. |
|