注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
好像是我第一次发面筋,昨天做了wepay的oa,没怎么准备因为已经有实习offer了,题目还是那两道。 不新鲜就不隐藏了。
第一题是每年10月的第二个星期二被认为是adaloving day,然后函数输入是year,要求返回adaloving day是该year的第几天。
解题思路:
我用python做的,所以直接调用 calendar.weekday(year, 10, i) == 1,则代表星期二。这样count到第二个星期二,返回 i 就行。
第二题是Alerter,题目表诉如下:
The Alerter is a simple monitoring tool, intended to help detect increases in response time for some process.
It does that by computing a few statistics about the process across a 'window' of a certain number of runs,
and alerting (returning true) if certain thresholds are met.
It takes the following parameters:
- inputs : A list of integer times for the process. This list may be very longax才高于window avg啊,所以感觉不能这么写。但是想保证时间复杂度在 O(n)而不是O(n*windowSize),自己想不出特别好的解决办法,可能是楼主刷的题太少没什么灵感。求一起讨论。
这里指出两个坑:
Any value is more than the allowed increase above the window average in ALL windows in which it appears. 的 all
和
Any window's average is more than the acceptable increase over any previous window's average value. 的 any
注意这两点应该就能过所有test case了
|