tag:blogger.com,1999:blog-8522573717713847738.post3535547122336675000..comments2024-03-28T00:14:29.070-07:00Comments on Yu's Coding Garden : leetcode Question 118: Valid NumberAnonymoushttp://www.blogger.com/profile/00263085222060621782noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-8522573717713847738.post-13404317528893474122016-09-07T04:07:23.720-07:002016-09-07T04:07:23.720-07:00Could this not be solved with regular expressions?...Could this not be solved with regular expressions?Anonymoushttps://www.blogger.com/profile/15926620974696771010noreply@blogger.comtag:blogger.com,1999:blog-8522573717713847738.post-38658202400979416102016-08-26T11:31:14.042-07:002016-08-26T11:31:14.042-07:00Hi, your code is not right. Consider this case: &q...Hi, your code is not right. Consider this case: "1.E+10" , your program result is true, but obviously, this is not a valid number.Anonymoushttps://www.blogger.com/profile/11258559881683684735noreply@blogger.comtag:blogger.com,1999:blog-8522573717713847738.post-89388597320952642102016-02-06T07:39:10.690-08:002016-02-06T07:39:10.690-08:00Below line is throwing exception for input "....Below line is throwing exception for input "."<br />if (s[s.size()-1]=='.' && !dot && !e && s[s.size()-2]>='0' && s[s.size()-1]<='9')<br />Please add the condition "s.size()-1 >= 0" ajit kumarhttps://www.blogger.com/profile/17856243789953360823noreply@blogger.comtag:blogger.com,1999:blog-8522573717713847738.post-44363992834327621362014-03-19T06:25:44.439-07:002014-03-19T06:25:44.439-07:00Thanks for the reply. I have checked the code, I f...Thanks for the reply. I have checked the code, I figured out that the problem is "E" and "e", in my code the "E" is not considered. <br /><br />I have modified the code. Please check.<br /><br />Thanks!<br />Anonymoushttps://www.blogger.com/profile/00263085222060621782noreply@blogger.comtag:blogger.com,1999:blog-8522573717713847738.post-87495834118583644722014-03-19T01:18:00.739-07:002014-03-19T01:18:00.739-07:00Hi, your code is not right. Consider this case: &q...Hi, your code is not right. Consider this case: "-.23E+10" , your program result is false, but obviously, this is a valid numberAnonymoushttps://www.blogger.com/profile/17246711294409866927noreply@blogger.comtag:blogger.com,1999:blog-8522573717713847738.post-52640686842180514722014-01-02T10:57:36.455-08:002014-01-02T10:57:36.455-08:00You can definitely add big "E" case, and...You can definitely add big "E" case, and for the "+/-" case, I think I already considered that in my code. Thanks!Anonymoushttps://www.blogger.com/profile/00263085222060621782noreply@blogger.comtag:blogger.com,1999:blog-8522573717713847738.post-16233216479659755242014-01-02T03:35:48.547-08:002014-01-02T03:35:48.547-08:00'+' and '-' could follow 'e...'+' and '-' could follow 'e' or 'E'. e.g. +1.1e-2CodeRecipehttps://www.blogger.com/profile/06916242913634632075noreply@blogger.com