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

Snap VO挂经

全局:

2021(1-3月) 码农类General 硕士 全职@snapchat - 网上海投 - Onsite  | | Fail | 在职跳槽

注册一亩三分地论坛,查看更多干货!

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

x
比较混乱的面试,体验比较差。电面其实没有表现好,托一个国人大哥照顾,让我过了。VO总共5轮。recruiter之前告诉我是两轮design,两轮coding再加一轮behavior。结果就问了一轮design 。

round 1: 30min past projects + 30min design snap story. Similar to design news feed, with one caveat that, snaps are only valid for 24 hours.
round 2: almost 30min behavior. The interviewer wanted to leave 5 minutes for QA, which means I need to solve the coding problem in about 25 minutes. It's actually LC 霸气一 but I didn't know. Spent some time figuring out the solution and was asked to write code. It was a mess. Definitely failed.
round 3: 30min behavior interview with an EM. Nothing to highlight. One que
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
As experienced candidate, I was expecting more focus on design and less coding. Instead they asked me three coding problems and just a little bit design. Two of the three coding problems (rounds 2 and 5) are hard. The other one (round 4) is definitely not that easy, even though it doesn't involve fancy idea. You'll see when I post my code later.

求大米

评分

参与人数 12大米 +19 收起 理由
wk93210 + 1 赞一个
cais2002 + 1 很有用的信息!
liusiyu + 2 给你点个赞!
Luptior + 2 很有用的信息!
guanhoo + 2 很有用的信息!

查看全部评分


上一篇:[吐槽!!!] 04/2021-苹果两轮电面(挂)经
下一篇:西三店面

本帖被以下淘专辑推荐:

推荐
 楼主| amzn_chou 2021-5-2 12:33:01 | 只看该作者
全局:
本帖最后由 amzn_chou 于 2021-5-2 12:36 编辑

这是我的代码:
  1. public class PayChange {

  2.     // This keeps track all the denominations the cashier has in the register.
  3.     // We use a reverse ordered TreeMap because we always want to find the change
  4.     // with larger denominations. For example, if we want to find $2.65, we'll first
  5.     // check if there is any $100, then $20, then $10, $5 and $1, etc.
  6.     // All the denominations are converted to cents. For example if we have 3 dollars
  7.     // in the register, it would be stored as 100 -> 3.
  8.     private final TreeMap<Integer, Integer> register;

  9.     public PayChange(TreeMap<Integer, Integer> register) {        assert Collections.reverseOrder().equals(register.comparator());
  10.         this.register = register;
  11.     }

  12.     /**
  13.      * When you buy something in grocery, the cashier needs to pay the change. Write a method simulating how the cashier
  14.      * find all the changes. For example you paid $5 for something worth $2.35, the cashier needs to find 2 $1, 6 dimes
  15.      * and 5 one cents if there are enough of these.
  16.      */
  17.     public boolean payChange(Map<Integer, Integer> paid, int price) {
  18.         int totalPaid = 0;
  19.         for (int denomination : paid.keySet()) {
  20.             totalPaid += denomination * paid.get(denomination);
  21.         }

  22.         // Not enough to cover the price.
  23.         if (totalPaid < price) {
  24.             return false;
  25.         }

  26.         // First we need to check if there is a solution, w/o actually paying the change.
  27.         // Maybe there isn't a solution.
  28.         int change = totalPaid - price;
  29.         Map<Integer, Integer> possibleChange = new HashMap<>();
  30.         for (int denomination : register.keySet()) {
  31.             int needed = change / denomination;
  32.             // We also have to consider what we have from the customer, not just what we have in the register.
  33.             int nReduced = Math.min(needed, register.get(denomination) + paid.getOrDefault(denomination, 0));
  34.             if (nReduced > 0) {
  35.                 change -= nReduced * denomination;
  36.                 possibleChange.put(denomination, nReduced);
  37.             }

  38.             if (change == 0) {
  39.                 break;
  40.             }
  41.         }

  42.         // This means we cannot find the proper combination.
  43.         if (change > 0) {
  44.             return false;
  45.         }

  46.         // Add back what the customer paid to the register.
  47.         for (int denomination : paid.keySet()) {
  48.             register.put(denomination, register.getOrDefault(denomination, 0) + paid.get(denomination));
  49.         }

  50.         // Actually remove denominations from the register.
  51.         for (int denomination : possibleChange.keySet()) {
  52.             int nRemaining = register.get(denomination) - possibleChange.get(denomination);
  53.             if (nRemaining == 0) {
  54.                 register.remove(denomination);
  55.             } else {
  56.                 register.put(denomination, nRemaining);
  57.             }
  58.         }
  59.         return true;
  60.     }
  61.     @Override
  62.     public String toString() {
  63.         return register.toString();
  64.     }

  65.     public static void main(String[] args) {
  66.         TreeMap<Integer, Integer> register = new TreeMap<>(Collections.reverseOrder());
  67.         register.put(100, 5);
  68.         register.put(25, 4);
  69.         register.put(1, 20);
  70.         PayChange payChange = new PayChange(register);

  71.         Map<Integer, Integer> paid = new HashMap<>();
  72.         paid.put(500, 1);
  73.         System.out.println(payChange.payChange(paid, 235));
  74.         System.out.println(payChange);
  75.     }

  76. }
复制代码


回复

使用道具 举报

推荐
noi10 2021-5-6 15:46:22 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
回复

使用道具 举报

推荐
 楼主| amzn_chou 2021-5-2 12:25:19 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies

评分

参与人数 1大米 +1 收起 理由
tcomein2009 + 1 很有用的信息!

查看全部评分

回复

使用道具 举报

🔗
limuqi 2021-5-1 14:48:05 | 只看该作者
全局:
很赞,谢谢分享,感觉你差一点就都做出来了
回复

使用道具 举报

🔗
tcomein2009 2021-5-2 10:21:06 | 只看该作者
全局:
辛苦楼主了

请问round 4 是刷题王 散儿儿吗?
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-0FRAZ  2021-5-2 10:22:40
加米加米
请问第五题是LC哪道啊?
谢谢
回复

使用道具 举报

🔗
noi10 2021-5-2 14:46:50 | 只看该作者
全局:
onsite可以分两天面吗?这样是不是好一点,一天面5轮有点累?
回复

使用道具 举报

🔗
q4chu 2021-5-11 13:05:42 | 只看该作者
全局:
第5题看起来应该是sliding window来做?
回复

使用道具 举报

🔗
q4chu 2021-5-11 13:06:47 | 只看该作者
全局:
noi10 发表于 2021-5-6 15:46
请问面额是固定的吗?就是dollor,dime,cent这样?
要是面额是 1,3,4,5  各一个, target amount是7 ...

我感觉这个应该得用dfs+memo做?主要每个硬币有数量的话,感觉还是得dfs
回复

使用道具 举报

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

本版积分规则

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