This is very slow for certain values (i. e. 1900000000).
1900000000
Use spoiler flag next time please.
This comment is hidden because it contains spoiler information about the solution
First argument is the pattern we want to find in the string. The pattern can be a string or Regex. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
Second argument is the replacement. It can be a string or a function. If the string is emtpty, we essentially just remove the pattern. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace
What does .replace() do?
same solution)
It's regular expressions, they are not supposed to be readable. It's a great tool that you shouldn't avoid just because it doesn't look pretty.
Inefficient, but super clever!
Good grief. Mine is awfully clumsy by comparison... Very nice.
I dont understand this solution. Can you explain it to me sir? I would like to learn that
I really like this solution. My one thought is if there are potentially a lot of duplicates, would it make sense to check if words[n] exists before setting calling num2word again?
words[n]
num2word
While it's true that this could be approximately twice as fast, the complexity is still the same (constant factors are ignored).
yeah, great solution.
Loading collection data...
This is very slow for certain values (i. e.
1900000000
).Use spoiler flag next time please.
This comment is hidden because it contains spoiler information about the solution
First argument is the pattern we want to find in the string. The pattern can be a string or Regex. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
Second argument is the replacement. It can be a string or a function. If the string is emtpty, we essentially just remove the pattern.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace
What does .replace() do?
same solution)
It's regular expressions, they are not supposed to be readable. It's a great tool that you shouldn't avoid just because it doesn't look pretty.
Inefficient, but super clever!
Good grief. Mine is awfully clumsy by comparison... Very nice.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I dont understand this solution. Can you explain it to me sir? I would like to learn that
I really like this solution. My one thought is if there are potentially a lot of duplicates, would it make sense to check if
words[n]
exists before setting callingnum2word
again?While it's true that this could be approximately twice as fast, the complexity is still the same (constant factors are ignored).
yeah, great solution.
Loading more items...