It is disheartening seeing how many "Senior" Software Engineers with over a decade of experience fail to implement `bool isNumber(const char*)` that works for positive/negative integers and decimals.
And these people somehow get past the filtering that our recruiters (large social network headquartered in the Bay Area) are supposed to perform.
Honestly exactly for this reason, I've been feeling a lot less passionate about conducting interviews than I did when I started my current job.
* there is no length argument
* localization, should it contain dots or commas?
* the minus sign or a plus sign should be only at start
* there should be only a single decimal separator
* just a dot is not a number
* just a minus or plus sign is not a number
* empty string is not a number
* there should be only a single minus or plus sign
* there should be a minus OR a plus sign
* let's assume something like .0 or 0. is allowed
* let's assume 4E04 is not allowed (although it is a positive integer)
And yes, you're correct at all of those assumptions. :)
This is one of the problems with these types of questions, including the CS 101 type questions that often make up purported coding tests during hiring. In most cases, they do not test what practicing software engineers actually do.
Yes, for a lot of problems you should go for stack overflow or a book. But this is a simple problem. SO won't have the solutions to all of your problems
In the context of an interview, it is highly likely a highly experienced software engineer will miss some of the corner cases. The exception would mostly be someone who has specifically studied and drilled on implementing isNumber(char * string) or specifically works in implementing these kind of functions which is rare. As I said there are libraries with these today.