I know I'm 2 years late, but his code is about ~3 faster. Tested it with 1 and 10 million executions.
Wow, your solution is honeslty great, I'll be taking inspiration to optimize mine as well!
👍
oh wow, this String method avoid adding \ in the pattern way, should we consider this one as better best practices?
For some reason the formulas are easier to read without PEP spacing. Not that you are wrong.
Look at my solution if you want some ideas about how to optimise yours (removing 2nd loop for example).
By the way, instead of parsing int you can use the following ascii tip : s.charAt(i) - '0'. Look at the ascii table and you will get why it works :)
Loading collection data...
I know I'm 2 years late, but his code is about ~3 faster. Tested it with 1 and 10 million executions.
Wow, your solution is honeslty great, I'll be taking inspiration to optimize mine as well!
👍
oh wow, this String method avoid adding \ in the pattern way, should we consider this one as better best practices?
For some reason the formulas are easier to read without PEP spacing. Not that you are wrong.
Look at my solution if you want some ideas about how to optimise yours (removing 2nd loop for example).
By the way, instead of parsing int you can use the following ascii tip : s.charAt(i) - '0'.
Look at the ascii table and you will get why it works :)