Convert Number to Words (Hard)

Good morning! Here's our prompt for today.

You may see this problem at Slack, Dropbox, Two Sigma, Procore, Airtable, Lucid Software, Fastly, Zoom, Sailpoint, and Okta.

Can you convert a number to its text equivalent? This is otherwise known as number spelling.

Description

For example, given 1234, we expect to get "one thousand two hundred and thirty four" back.

Constraints

  • The given number will have <= 100 digits
  • Let n be the number of digits
  • Expected time complexity : O(n)
  • Expected space complexity : O(n)
JAVASCRIPT
OUTPUT
Results will appear here.