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

Dropbox挂经换米

🔗
 楼主| zsll 2016-12-23 06:38:03 | 只看该作者
全局:
274132666 发表于 2016-12-20 20:05
楼主之前电面面的什么题呀

电面我直接贴代码了,一共两轮,都是面经常见的:1是找重复文件,2是给电话号码找能由字典中的词组成的号码
  1. Recruiter feedback:
  2. Coding needs hints
  3. Not enough attention to detail
  4. Interviewers think it's flat, it will need more spikes



  5. Interview Outline:
  6. 1 presentation
  7. 9:45 - 5:45
  8. 2 - 3 coding questions (data structure)

  9. concurrency
  10. coding about multi-threading, event driving program

  11. 1 cultrual interview (your recent project, how you tackle problem, how you work with your team, your personal passion, impact other people in the company
  12. What if your team is not doing well. Do you tell your manager. Do you do nothing
  13. How do you
  14. )
  15. project deep dive interview (15 - 25minutes, drive, how to refine)

  16. 1 hiring manager (professional development)





  17. Phone interview 1:
  18. import java.io.*;
  19. import java.util.*;

  20. /*
  21. * To execute Java, please define "static void main" on a class
  22. * named Solution.
  23. *
  24. * If you need more classes, simply define them inline.
  25. */
  26. //1 m, phone issue
  27. //I am starting my phone

  28. // 👍

  29. //Something wrong, call failed

  30. // Yeah, hm, let's see if my personal phone works...
  31. // Can you join https://bluejeans.com/4273619641

  32. class Solution {
  33.   public static void main(String[] args) {
  34.     print();
  35.   }
  36.   
  37.   static List<List<String>> findDuplicates(String path);
  38.     List<List<String>> res = new ArrayList<List<String>>();
  39.     if(path != null && path.length() > 0) {
  40.       List<List<String>> files = findFileOfSameSize(path);
  41.       for(List<String> filegroup : files) {
  42.         HashMap<String, List<String>> h = new HashMap<String, List<String>>();
  43.         HashSet<String> s = new HashSet<String>();
  44.         for(String f : filegroup) {
  45.           String hash = checksum(f);
  46.           if(!h.containsKey(hash)) {
  47.             h.put(hash, new ArrayList<String>());
  48.           }
  49.           h.get(hash).add(f);
  50.           if(h.get(hash).size() > 1) {
  51.             s.add(hash);
  52.           }
  53.         }
  54.         for(String hash : s) {
  55.           res.add(h.get(hash);
  56.         }
  57.       }
  58.     }
  59.     return res;
  60.   }

  61.   static List<List<String>> findFileOfSameSize(String path) {
  62.     List<List<String>> res = new ArrayList<List<String>>();
  63.     if(path != null && path.length() > 0) {
  64.       Stack<String> s = new Stack<String>();
  65.       s.push(path);
  66.       HashMap<Integer, List<String>> h = new HashMap<Integer, List<String>>();
  67.       HashSet<Integer> set = new HashSet<Integer>();
  68.       while(!s.empty()) {
  69.         String cur = s.pop();
  70.         if(!isDir(cur)) {
  71.           int size = getFileSize(cur);
  72.           if(!h.containsKey(size)) {
  73.             h.put(size, new ArrayList<String>());
  74.           }
  75.           h.get(size).add(cur);
  76.           if(h.get(size).size() > 1) {
  77.             set.add(size);
  78.           }
  79.         } else {
  80.            List<String> children = listDir(cur);
  81.            for(String child : children) {
  82.               s.push(child);
  83.            }
  84.         }
  85.       }
  86.       for(Integer size : set) {
  87.         res.add(h.get(size));
  88.       }
  89.     }
  90.     return res;
  91.   }
  92.   
  93. }

  94. // List<List<String>> findDuplicates(String path);

  95. // /foo/bar.txt -> 'hello'
  96. // /baz.txt -> 'bye'
  97. // /bat.txt -> 'hello'
  98. // /three.four -> 'hello'

  99. // '/' -> [['/foo/bar.txt', '/baz.txt', '/three.four']]
  100. //String checkSum(String path)

  101. // bool isDir(String path)
  102. // int getFileSize(String filePath)
  103. // List<String> listDir(String path)
  104. // String joinPath(directory, path)


  105. //If there is a symlink 怎么办,防止loop


















  106. Phone Interview 2:

  107. import java.io.*;
  108. import java.util.*;

  109. /*
  110. * To execute Java, please define "static void main" on a class
  111. * named Solution.
  112. *
  113. * If you need more classes, simply define them inline.


  114. 1 - nothing
  115. 2 - ABC
  116. 3 - DEF
  117. 4 - ...
  118. ...
  119. 7 - PQRS
  120. ...
  121. 9 - WXYZ
  122. 0 - nothing

  123. 1-800-FASTCAR
  124. 1-800-DROPBOX
  125. 1-800-376....

  126. 4667364 -> what word(s) can be made from this number (return as list)

  127. dictionary is 50k
  128. */

  129. class Solution {
  130.   public static void main(String[] args) {
  131.     HashSet<String> dict = new HashSet<String>();
  132.     dict.add("fast");
  133.     dict.add("car");
  134.     dict.add("drop");
  135.     dict.add("box");
  136.     dict.add("exactly"); //3922859
  137.     dict.add("ken");
  138.     dict.add("park");
  139.     dict.add("kenpark");
  140.     //HashSet<String> res = find("3922859", dict);
  141.     HashSet<String> res = find("5367275", dict);
  142.     //dfs(dict, res, new StringBuffer(), "222");
  143.     for(String s : res) {
  144.       System.out.println(s);
  145.     }
  146.    
  147.    
  148.    
  149.   }
  150.   
  151.   
  152.   
  153.   static void find2(String query, HashSet<String> dict, int start, List<HashSet<String>> pre, HashSet<String> res) {
  154.     if(start == query.length()) {
  155.       dfs2(res, pre, new StringBuffer(), 0);
  156.     } else {
  157.       for(int i = start + 3; i < query.length(); i++) {
  158.         String subQuery = query.substring(start, i);
  159.         HashSet<String> subRes = new HashSet<String>();
  160.         dfs(dic, subRes, new StringBuffer(), subQuery);
  161.         if(subRes.size() > 0) {
  162.           pre.add(subRes);
  163.           find2(query, dict, i, pre);
  164.           pre.remove(pre.size() - 1);
  165.         }
  166.       }
  167.     }
  168.   }
  169.   
  170.   void dfs2(HashSet<String> res, List<HashSet<String>> pre, StringBuffer sb, int start) {
  171.       if(start == pre.size()) {
  172.         res.add(new String(sb));
  173.       } else {
  174.         for( String s : pre.get(start)) {
  175.           int oriLen = sb.length();
  176.           sb.append(s);
  177.           dfs2(res, pre, sb, start + 1);
  178.           sb.setLength(oriLen);
  179.         }
  180.       }
  181.   }
  182.   
  183.   
  184.   static HashSet<String> find(String query, HashSet<String> dict) {
  185.     HashSet<String> res = new HashSet<String>();
  186.     if(query != null && query.length() == 7 && dict != null) {
  187.       String a1 = query.substring(0, 4), b1 = query.substring(4, 7);
  188.       HashSet<String> firstRes = findHelper(a1, b1, dict);
  189.       res.addAll(firstRes);
  190.       a1 = query.substring(0, 3);
  191.       b1 = query.substring(3, 7);
  192.       HashSet<String> secRes = findHelper(a1, b1, dict);
  193.       res.addAll(secRes);
  194.       HashSet<String> thirdRes = new HashSet<String>();
  195.       dfs(dict, thirdRes, new StringBuffer(), query);
  196.       res.addAll(thirdRes);
  197.     }
  198.     return res;
  199.   }
  200.          
  201.   static HashSet<String> findHelper(String a1, String b1, HashSet<String> dict) {
  202.     HashSet<String> a1Res = new HashSet<String>();
  203.     dfs(dict, a1Res, new StringBuffer(), a1);
  204.     HashSet<String> b1Res = new HashSet<String>();
  205.     dfs(dict, b1Res, new StringBuffer(), b1);
  206.     HashSet<String> res = new HashSet<String>();
  207.     for(String a : a1Res) {
  208.       for(String b : b1Res) {
  209.         res.add(a + b);
  210.       }
  211.     }
  212.     return res;
  213.   }
  214.   
  215.   static void dfs(HashSet<String> dict, HashSet<String> res, StringBuffer sb, String query) {
  216.     if(sb.length() == query.length()) {
  217.       String word = new String(sb);
  218.       if(dict.contains(word)) {
  219.          res.add(word);
  220.       }
  221.     } else {
  222.       char [][] keys = {
  223.         {' '},
  224.         {' '},
  225.         {'a','b','c'},
  226.         {'d','e','f'},
  227.         {'g','h','i'},
  228.         {'j','k','l'},
  229.         {'m','n','o'},
  230.         {'p','q','r','s'},
  231.         {'t','u','v'},
  232.         {'w','x','y','z'}
  233.       };
  234.       int pos = sb.length();
  235.       char [] chars = keys[query.charAt(pos) - '0'];
  236.       for(char c : chars) {
  237.         sb.append(c);
  238.         dfs(dict, res, sb, query);
  239.         sb.deleteCharAt(sb.length() - 1);
  240.       }
  241.     }
  242.   }
  243. }
复制代码

评分

参与人数 4大米 +19 收起 理由
frk + 3 很有用的信息!
江城渔翁 + 1 给你点个赞!
ForTheKing + 5 很有用的信息!
FightOn + 10 很有用的信息!

查看全部评分

回复

使用道具 举报

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

使用道具 举报

🔗
feyhi 2016-12-23 15:22:49 | 只看该作者
全局:
想了一会,所以page table是存phone directory的page的table,不是内存的page table?不然就是黑科技了>.<
可是O(N/1000)还是O(N)呀,只是降了系数
回复

使用道具 举报

🔗
shelly1996 2017-1-5 11:24:11 | 只看该作者
全局:
zsll 发表于 2016-12-23 06:38
电面我直接贴代码了,一共两轮,都是面经常见的:1是找重复文件,2是给电话号码找能由字典中的词组成的号 ...

楼主好人,谢楼主!
回复

使用道具 举报

🔗
tommyhahn 2017-1-16 13:27:17 | 只看该作者
全局:
楼主请问电面1 中如果有symlink 是怎么解决的啊?
回复

使用道具 举报

🔗
刘心惠 2017-2-8 16:19:13 | 只看该作者
全局:
请问下楼主,他家new grad也会要求多线程之类的问题吗?一提多线程,怎么那么慌
回复

使用道具 举报

🔗
shelly1996 2017-2-8 22:35:48 | 只看该作者
全局:
刘心惠 发表于 2017-2-8 16:19
请问下楼主,他家new grad也会要求多线程之类的问题吗?一提多线程,怎么那么慌

基本没准备去面的,不知道啊

补充内容 (2017-2-8 22:36):
无视我....
回复

使用道具 举报

🔗
 楼主| zsll 2017-2-8 23:04:31 | 只看该作者
全局:
tommyhahn 发表于 2017-1-16 13:27
楼主请问电面1 中如果有symlink 是怎么解决的啊?

这属于写完以后瞎聊的问题 我就说用hash
回复

使用道具 举报

🔗
 楼主| zsll 2017-2-8 23:05:26 | 只看该作者
全局:
刘心惠 发表于 2017-2-8 16:19
请问下楼主,他家new grad也会要求多线程之类的问题吗?一提多线程,怎么那么慌

我不是new grad 所以不敢保证
回复

使用道具 举报

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

本版积分规则

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