回复: 26
跳转到指定楼层
上一主题 下一主题
收起左侧

twitter oa 一問

全局:

2017(10-12月) 码农类General 本科 实习@twitter - 校园招聘会 - 在线笔试  | | Other | 应届毕业生
正在做能寫一星期的twiiter
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
的人,能給點提示嗎

本帖子中包含更多资源

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x

上一篇:刚来美帝的新手想请大家告诉一下我电面流程,在哪写代码啊??
下一篇:请问有做过cisco OA的同学吗?
推荐
 楼主| gavin5566 2016-10-26 09:41:52 | 只看该作者
全局:

行 各種語言都可以
回复

使用道具 举报

推荐
EasonS 2016-10-30 10:02:27 | 只看该作者
全局:
# Enter your code here. Read input from STDIN. Print output to STDOUT
# need to check if in range
import sys
import collections

def validTimeRange (curTime, timeRange):
    minYear = int(timeRange[0][:4])
    minMonth = int(timeRange[0][-2:])
    maxYear = int(timeRange[1][:4])
    maxMonth = int(timeRange[1][-2:])
    curYear = int(curTime[:4])
    curMonth  = int(curTime[-2:])
    if (curYear < minYear or curYear > maxYear or
        (curYear == minYear and curMonth < minMonth) or
        (curYear == maxYear and curMonth >= maxMonth)):
        return False
    else:
        return True
   
   
def splitWithOptionalSpace (curLine, nextLine):
    engagement_index = 11
    if (nextLine[11] == ' '):
        engagement_index += 1
    engagement = ''
    while(nextLine[engagement_index] != ','):
        engagement += nextLine[engagement_index]
        engagement_index += 1
    curLine.append(engagement)
    count_index = engagement_index + 1
    if (nextLine[count_index] == ' '):
        count_index += 1
    count = ''
    while(nextLine[count_index] != '\n'):
        count += nextLine[count_index]
        count_index += 1
    curLine.append(count)
   
   
   
timeRange = sys.stdin.readline().split(', ')

sys.stdin.readline()

nextLine = sys.stdin.readline()
# string : {}
# {} is string : int
ret = {}
while (nextLine != ''):
    curLine = [nextLine[:10]]
    # deal with fields seperated by optional space
    splitWithOptionalSpace (curLine, nextLine)
    # test if time is in valid range
    curTime = curLine[0][:7]
    if (validTimeRange(curTime, timeRange) is False):
        nextLine = sys.stdin.readline()
        continue
    # aggregate one line to the structure we want
    if curTime not in ret:
        ret[curTime] = {curLine[1] : int(curLine[2])}
    else:
        if curLine[1] in ret[curTime]:
            ret[curTime][curLine[1]] += int(curLine[2])
        else:
            ret[curTime][curLine[1]] = int(curLine[2])
   
    nextLine = sys.stdin.readline()

# format output
for entry in sorted(ret.items(), key=lambda x: x[0], reverse=True):
    toPrint = entry[0] + ', '
    for subEntry in sorted(entry[1].items(), key=lambda x: x[0]):#, reverse=True):
        toPrint += subEntry[0] + ', ' + str(subEntry[1]) + ', '
    sys.stdout.write(toPrint[:-2] + '\n')
            

全过

评分

参与人数 1大米 +8 收起 理由
jigsaw_Becky + 8 感谢分享!

查看全部评分

回复

使用道具 举报

推荐
skysbjdy 2016-10-27 08:05:14 | 只看该作者
全局:

array里面的元素 有没有说全是正数??   还是正负 都有可能??  leetcode有个类似的 是求最短subarray sum >= k正好跟这个相反, 但是限制了array里面的数全是正数
回复

使用道具 举报

🔗
qizy09 2016-10-25 16:29:02 | 只看该作者
全局:
楼主别的题能也发一下吗?
回复

使用道具 举报

🔗
sophie729 2016-10-25 18:42:23 | 只看该作者
全局:
一个都没过 但是ide 完全 ok 不知道为啥
回复

使用道具 举报

🔗
 楼主| gavin5566 2016-10-25 23:36:04 | 只看该作者
全局:
sophie729 发表于 2016-10-25 18:42
一个都没过 但是ide 完全 ok 不知道为啥

對啊 只過一個
回复

使用道具 举报

🔗
j20120307 2016-10-26 05:35:15 | 只看该作者
全局:
你这一共几道题?
回复

使用道具 举报

🔗
yangmyfly 2016-10-26 05:36:56 | 只看该作者
全局:
问下能用c++么
回复

使用道具 举报

🔗
 楼主| gavin5566 2016-10-26 09:41:40 | 只看该作者
全局:
j20120307 发表于 2016-10-26 05:35
你这一共几道题?

四道題目
sql + 3題coding
回复

使用道具 举报

🔗
dlys3000 2016-10-26 09:48:58 | 只看该作者
全局:
卡了两天?twitter的oa限时好几天?谢谢
回复

使用道具 举报

🔗
wujingzhishui 2016-10-26 09:58:06 | 只看该作者
全局:
没做过但是觉得这题思路很明显,
TreeMap<data, list<list<Integer>>> 这样做应该就出结果了吧,
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

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