用这种难度的题目面试程序员,给多少时间合适?

2020-09-05 03:17:12 +08:00
 lihongming

Julia conducted a 15 days of learning SQL contest. The start date of the contest was March 01, 2016 and the end date was March 15, 2016.

Write a query to print total number of unique hackers who made at least submission each day (starting on the first day of the contest), and find the hacker_id and name of the hacker who made maximum number of submissions each day. If more than one such hacker has a maximum number of submissions, print the lowest hacker_id. The query should print this information for each day of the contest, sorted by the date.


Input Format

The following tables hold contest data:


Sample Input

For the following sample input, assume that the end date of the contest was March 06, 2016.


Sample Output

2016-03-01 4 20703 Angela 2016-03-02 2 79722 Michael 2016-03-03 2 20703 Angela 2016-03-04 2 20703 Angela 2016-03-05 1 36396 Frank 2016-03-06 1 20703 Angela

Explanation

On March 01, 2016 hackers 20703, 36396, 53473 and 79722 made submissions. There are 4 unique hackers who made at least one submission each day. As each hacker made one submission, 20703 is considered to be the hacker who made maximum number of submissions on this day. The name of the hacker is Angela.

On March 02, 2016 hackers 15758, 20703 and 79722 made submissions. Now 20703 and 79722 were the only ones to submit every day, so there are 2 unique hackers who made at least one submission each day. 79722 made 2 submissions, and name of the hacker is Michael.

On March 03, 2016 hackers 20703, 36396 and 79722 made submissions. Now 20703 and 79722 were the only ones, so there are 2 unique hackers who made at least one submission each day. As each hacker made one submission so 20703 is considered to be the hacker who made maximum number of submissions on this day. The name of the hacker is Angela.

On March 04, 2016 hackers 20703, 44065, 53473 and 79722 made submissions. Now 20703 and 79722 only submitted each day, so there are 2 unique hackers who made at least one submission each day. As each hacker made one submission so 20703 is considered to be the hacker who made maximum number of submissions on this day. The name of the hacker is Angela.

On March 05, 2016 hackers 20703, 36396, 38289 and 62529 made submissions. Now 20703 only submitted each day, so there is only 1 unique hacker who made at least one submission each day. 36396 made 2 submissions and name of the hacker is Frank.

On March 06, 2016 only 20703 made submission, so there is only 1 unique hacker who made at least one submission each day. 20703 made 1 submission and name of the hacker is Angela.

4454 次点击
所在节点    程序员
34 条回复
lihongming
2020-09-05 03:23:08 +08:00
奇了个怪了,table 为何不能正确解析?
msg7086
2020-09-05 04:54:55 +08:00
面程序员还是面数据相关岗位?
lihongming
2020-09-05 05:38:07 +08:00
@msg7086 程序员,除了这个还有算法题,时间另计
way2explore2
2020-09-05 06:22:44 +08:00
取决于什么条件。

如果是现场做,最多给两个小时。

如果带回家,我会周一发,然后让周五交。
msg7086
2020-09-05 07:00:57 +08:00
@lihongming 面程序员的话我压根不会出 SQL 的题。
如果是面数据库方向的话,更多的会放在讨论表结构设计,索引优化这一块吧。
我最近几年的工作都不需要写 SQL 操作数据库。
lihongming
2020-09-05 08:24:19 +08:00
@msg7086 问题是这事咱俩说了不算啊。

现在就是要考 SQL 了,现场给题现场做,允许 Google,只能想想给多少时间合适了。
sealingpp
2020-09-05 08:25:03 +08:00
这全英文的,薪资范围多少,针对 什么级别的
lihongming
2020-09-05 08:26:27 +08:00
@way2explore2 两个小时……那看来现场考不太合适,太久了
shakoon
2020-09-05 08:46:32 +08:00
看你招的是什么级别的人。如果是高级的,这玩意 10 分钟还完不成那赶紧撵走吧,简历基本是吹牛的。中级建议 20 分钟,初级建议 35 分钟。我觉得这个题并不难啊,楼上怎么会有人觉得需要两小时的?
cnxiaowen
2020-09-05 09:23:11 +08:00
@shakoon 读题目一个半小时
heiheidewo
2020-09-05 09:26:48 +08:00
题目太长了,是我就直接走人了
SergeGao
2020-09-05 09:30:59 +08:00
不懂 sql 的前端表示这题看起来好像是入门级别的吧...
richard1122
2020-09-05 10:02:22 +08:00
看起来不难啊,不过 score 字段好像没用处?
这里找“每日最佳”是提交数量最多,并且 0 分也算有效提交
pigzzz
2020-09-05 10:26:12 +08:00
外企公司吗
fishCatcher
2020-09-05 10:55:47 +08:00
题目本质不难,还是弄短一点适合面试
rioshikelong121
2020-09-05 11:20:20 +08:00
题干太长了 直接走人。
newtype0092
2020-09-05 12:15:46 +08:00
newtype0092
2020-09-05 12:19:22 +08:00
sorry 点错发出去了。。。

每日最多提交这个条件很简单。
前面要求找出每天的符合"从开始到今日每天都有过提交"的人数,这个不知道大家什么思路?有没有什么优雅的办法不用复杂连表能解出来的?
newtype0092
2020-09-05 12:21:18 +08:00
@shakoon 大佬能提供下思路么?
sunbeams001
2020-09-05 13:27:03 +08:00
说下个人思路
先按照 hackerid+日期 分组,对结果集再按照 hackerid 分组,限制聚合计数为 15,即可得到每天都提交过的 hackerid
求更优雅的解法

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/704379

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX