We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
That's probably the best approach to this issue. The reason C#'s built-in parse is so slow is that it has to check for all kinds of invalid input, which includes checking each char to ensure it's a digit. e.g. int.Parse will throw a FormatException if you feed it "32a1" while this method will return 3691, since 'a' gets converted to 49.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Dijkstra: Shortest Reach 2
You are viewing a single comment's thread. Return to all comments →
That's probably the best approach to this issue. The reason C#'s built-in parse is so slow is that it has to check for all kinds of invalid input, which includes checking each char to ensure it's a digit. e.g. int.Parse will throw a FormatException if you feed it "32a1" while this method will return 3691, since 'a' gets converted to 49.