Integer to English Words

[LeetCode]

​https://leetcode.com/problems/integer-to-english-words/​

Total Accepted: 3589 Total Submissions: 24432 Difficulty: Medium

Question

Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.

​https://leetcode.com/problems/integer-to-english-words/​

Examples

For example,


123 -“One Hundred Twenty Three”

12345 -“Twelve Thousand Three Hundred Forty Five”

1234567 -“One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven”


Ways

将数每三位划分一段,每一段都是一个三位数,将三位数读出来,再带上对应的数级即可。

Solution

托管在我的GitHub上:

​https://github.com/fuxuemingzhu/Integer2Words​

Captures

测试结果截图:

为啥效率排名这么低?

Reference

Date

2015/9/16 0:12:11