【LeetCode】Integer to English Words 解题报告

来源:互联网 发布:天刀捏脸数据成男网盘 编辑:程序博客网 时间:2024/05/16 07:23

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

0 0
原创粉丝点击