tag:blogger.com,1999:blog-3861200916183859809.post5635432100205777456..comments2018-04-16T12:09:54.580+05:30Comments on Perl Quiz: Quiz 80: Remove leading zeros from an array of positive integerssaurabh2k26http://www.blogger.com/profile/00524123124401905843noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-3861200916183859809.post-47188940067848476602015-03-02T11:46:20.578+05:302015-03-02T11:46:20.578+05:30Constraints are provided in problem solution. Each...Constraints are provided in problem solution. Each element of array is < 1000000. I can use divide by 1 to make it work for any length.saurabh2k26https://www.blogger.com/profile/00524123124401905843noreply@blogger.comtag:blogger.com,1999:blog-3861200916183859809.post-76950671327838711072015-03-02T11:43:50.056+05:302015-03-02T11:43:50.056+05:30Hi
your solution will not work for 00 or 0. Will g...Hi<br />your solution will not work for 00 or 0. Will give NULL. Expected should be 0.saurabh2k26https://www.blogger.com/profile/00524123124401905843noreply@blogger.comtag:blogger.com,1999:blog-3861200916183859809.post-42039907904130233132015-03-02T11:42:15.629+05:302015-03-02T11:42:15.629+05:30what if I have 12 leading zeroes. will your code w...what if I have 12 leading zeroes. will your code work properly? You are diving just by 10^6.<br /><br />Why don't you use Perl's most powerful weapon that is regex :)<br /><br />$str =~ s/^0+//g'; and then do split and print array :)Alien Codershttps://www.blogger.com/profile/07437929670690745122noreply@blogger.comtag:blogger.com,1999:blog-3861200916183859809.post-82656306818545503812015-02-26T21:45:46.820+05:302015-02-26T21:45:46.820+05:30echo '007 70 01022 0000000001 00200 20000 0012...echo '007 70 01022 0000000001 00200 20000 0012300' | perl -pe 's/\b0+//g'Anonymousnoreply@blogger.com