how did they find out if the passed string is a number or not from the length.
or
is there a way to determine whether a string is a number from the length of the string.
i m totally confused.
Stephen Haokip
Level 13
line 57 of the correct solution
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Lisa
30 December 2021, 09:40
I don't know the CG solution but there's a method isNumber() in the given code that probably is used exactly for that purpose. That method checks each char of a passed string if it matches a digit or a minus sign. If it does not then it is not a number. If it is just a single minus sign or the minus sign is in the middle of the string, then the string is not a number.
0