May 2009 - May 2017 论坛八周年-你的足迹,我的骄傲


一亩三分地论坛

 找回密码
 获取更多干活,快来注册

一亩三分地官方iOS手机应用下载
查看: 1680|回复: 1
收起左侧

Yelp 10/07 on-campus

[复制链接] |试试Instant~ |关注本帖
abcd1992719g 发表于 2016-10-8 05:08:24 | 显示全部楼层 |阅读模式

2016(10-12月) 码农类 硕士 全职@Yelp - 网上海投 - 技术电面 |Otherfresh grad应届毕业生

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看,没有帐号?获取更多干活,快来注册

x
就一轮 是个亚裔姐姐. 先问了简历,然后问了网站访问比较慢 是哪些原因.
然后coding是比较简单数字转英文描述. 比如22是twenty two.

聊天也聊的很开心. 她老公在MTV她在城里


求star求follow  https://github.com/gzc

qiu_cqupt 发表于 2016-10-18 08:35:12 | 显示全部楼层
关注一亩三分地公众号:
Warald_一亩三分地
这道题挺难的啊。是lc hard number to english
  1. class Solution(object):
  2.     def __init__(self):
  3.         self.less20 = ["","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"]
  4.         self.tens = ["","Ten","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety"]
  5.         self.thousands = ["","Thousand","Million","Billion"]

  6.     def numberToWords(self, num):
  7.         """
  8.         :type num: int
  9.         :rtype: str
  10.         """
  11.         res = ''
  12.         index = 0
  13.         while num:
  14.             res = self.helper(num%1000) + ' ' + self.thousands[index] + ' ' + res
  15.             index += 1
  16.             num = num//1000

  17.         return res

  18.     def helper(self, num):

  19.         res = ''
  20.         if num>=100:. visit 1point3acres.com for more.
  21.             res = self.less20[num//100] + ' ' + 'Hundred'
  22.             num = num%100. 1point3acres.com/bbs
  23.         if num >=20:
  24.             res = res + (' ' if res else '') + self.tens[num//10] + (' ' if self.tens[num//10] else '') + self.less20[num%10]
  25.         else:
  26.             res = res + (' ' if res else '') + self.less20[num]
  27.         return res

  28. num = 2111111121. 1point3acres.com/bbs
  29. so = Solution()
  30. a = so.numberToWords(num)
  31. print(a)
复制代码
回复 支持 反对

使用道具 举报

本版积分规则

关闭

一亩三分地推荐上一条 /5 下一条

手机版|小黑屋|一亩三分地论坛声明 ( 沪ICP备11015994号 )

custom counter

GMT+8, 2017-5-27 07:24

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

快速回复 返回顶部 返回列表