面试半小时前刚结束但估计要凉先写下来回报社会。
额外一个hint:我本来以为meta会用zoom的whiteboard或者很fancy的screensharing去detect AI assistant 找了半天undetectable的AI coder没一个能正常在zoom下好好work的。但据我这次体验他就是个leetcode一样的东西,不会真的看有没有screensharing啥的。用PC的话打开自带的copilot小眼镜模式(screensharing),让他完全静音,面试前跟他说好要什么答案和解题思路,根本不需要自己在那傻写。胆子大的先享受世界好吧,我路给大家探好了反正虽然我就是那个勤恳debug的大傻子嘿嘿。
总共50min coding,25分钟3道算法,25分钟3道SQL
算法1:
find the comment with the most occuration across all locations
input:
{location1:["xya","abx", "xya"]
location2:["abc","abx"],
location3:["xya"]}
output:
"abx" or "xya" cause they both appeared twice, anyone of them is fine.
hint: "xya" in location1 is count as one time as duplicate comments should be ignored.
我写的loop一遍存成counter再binary search 那个counter里的value
算法2:
find the minimal odd numbers that can be made from the input
input:29031
output:139
input:2020
output:None
input:9999993333311
output:1133333999999
我写的input变list of str如果d%2==1,sort 完用join然后换回int
算法3:
(只剩1分钟算法连看题都没太来得及)什么bookstore event consecutive 2 years啥的。。。找到什么most啥啥啥 反正就return一个bookstore。我瞎跟面试官聊了一下思路就开始写sql题了。
============
SQL 都用的是书,交易,作者, ?(忘了因为完全没用到)四个dimension tables
SQL1:
找total sales 和total distinct customer from transactions table那种,基础题
SQL2:
找头5个customer他们referred的customer 买书avg payment最多。 用CTE 先找total payment from transaction tables(有个小陷阱per transaction can have more than 1 book, for avg we need to sum book_count), 然后return referred_by_customer_id order by avg_pay limit 5.
SQL3:
return一行数据,total author,percentage 的作者没有任何书(没有author_id在book table里),percentage的作者没有任何sales(transactions table里只有book ID 没有author id所以还得join回去).