注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
上周做了walmart的karat面试,形式是固定的:
前5分钟自我介绍
10分钟五类题目选两个快问快答,每一类各3道题
最后45分钟coding,基本都是简书里原题,一共三道题,三道题是followup的形式,题干类似,做出一道才会给下一题,45分钟一般能把前两题做完,第三题写一点思路。面试官会在main函数里贴出所有测试数据,需要自己打印出运行结果,所有结果都正确就是通过。
楼主做了两次,由于第一次没好好看题库,第二道coding没跑成功。于是又redo了一次,顺利走您好! 本帖隐藏的内容需要积分高于 188 才可浏览 您当前积分为 0。 使用VIP即刻解锁阅读权限或查看其他获取积分的方式 游客,您好! 本帖隐藏的内容需要积分高于 188 才可浏览 您当前积分为 0。 VIP即刻解锁阅读权限 或 查看其他获取积分的方式 列的模式后,和给定的模式比较这样做会比较简单一些。
redo这次的题目是badge这道题,前两道题目简书里有,下面是第三道题的题干。这道题没想到什么好思路,当时时间也不多了,随便说了几句。- /*
- We want to find employees who badged into our secured room together often. Given an unordered list of names and access times over a single day, find the largest group of people that were in the room together during two or more separate time periods, and the times when they were all present.
- John: {(455,enter), (512,exit), (1510, exit)}
- ->
- John: {{455,512}, {1000, 1510}}
- Steve: {{300, 500}}
- [John, Steve] : {{455, 500}}
- records = [
- ["Curtis", "2", "enter"],
- ["John", "1510", "exit"],
- ["John", "455", "enter"],
- ["John", "512", "exit"],
- ["Jennifer", "715", "exit"],
- ["Steve", "815", "enter"],
- ["John", "930", "enter"],
- ["Steve", "1000", "exit"],
- ["Paul", "1", "enter"],
- ["Angela", "1115", "enter"],
- ["Curtis", "1510", "exit"],
- ["Angela", "2045", "exit"],
- ["Nick", "630", "exit"],
- ["Jennifer", "30", "enter"],
- ["Nick", "30", "enter"],
- ["Paul", "2145", "exit"],
- ["Ben", "457", "enter"],
- ["Ben", "458", "exit"],
- ["Robin", "459", "enter"],
- ["Robin", "500", "exit"]
- ]
- Expected output:
- Paul, Curtis, and John: 455 to 512, 930 to 1510
- For this input data:
- From 455 til 512, the room contains Paul, Curtis and John. Jennifer and Nick are also in the room at this time, and Ben and Robin enter and leave during this time period.
- From 930 til 1510, Paul, Curtis, and John are in the room while Steve and Angela enter and leave, until Curtis leaves at 1510.
- The group "Paul, Curtis and John" exists at both of these times, and is the largest group that exists multiple times.
- You should note that the group in the expected output is a subset of the people in the room in both cases.
- records2 = [
- ["Paul", "1545", "exit"],
- ["Curtis", "1410", "enter"],
- ["Curtis", "222", "enter"],
- ["Curtis", "1630", "exit"],
- ["Paul", "10", "enter"],
- ["Paul", "1410", "enter"],
- ["John", "330", "enter"],
- ["Jennifer", "330", "enter"],
- ["Jennifer", "1410", "exit"],
- ["John", "1410", "exit"],
- ["Curtis", "330", "exit"],
- ["Paul", "330", "exit"],
- ]
- Expected output:
- Curtis, Paul: 222 to 330, 1410 to 1545
- All Test Cases:
- together(records) => Paul, Curtis, and John: 455 to 512, 930 to 1510
- together(records2) => Curtis, Paul: 222 to 330, 1410 to 1545
- n: length of the badge records array
- */
复制代码 } |