📣 独立日限时特惠: VIP通行证立减$68
楼主: abcd1992719g
跳转到指定楼层
上一主题 下一主题
收起左侧

snapchat两轮电话

🔗
daniel_hl 2016-9-3 12:28:50 | 只看该作者
全局:
abcd1992719g 发表于 2016-9-2 13:25
组合为0没关系  因为有最多取几次的参数

LZ是用DFS加memoization做的吗?
回复

使用道具 举报

全局:
wtcupup 发表于 2016-9-3 11:50
https://discuss.leetcode.com/topic/54105/snapchat-parse-cpu-log-file
上面是更全的例子
你可以试试 ...

谢谢分享, 我原先理解的是一个任务在end之前不能再来一个start, 看了那个帖子发现不是。 那应该用一个stack做就好啦
回复

使用道具 举报

🔗
pawprinter 2016-9-5 02:41:52 | 只看该作者
全局:
您好请问两轮是说一次面了两道题?
回复

使用道具 举报

🔗
 楼主| abcd1992719g 2016-9-5 02:48:36 | 只看该作者
全局:
pawprinter 发表于 2016-9-5 02:41
您好请问两轮是说一次面了两道题?

国人小哥面完一星期后黑人小哥面
回复

使用道具 举报

🔗
pawprinter 2016-9-5 03:13:52 | 只看该作者
全局:
abcd1992719g 发表于 2016-9-5 02:48
国人小哥面完一星期后黑人小哥面

多谢,请问您onsite了吗
回复

使用道具 举报

🔗
wanghwadad 2016-9-5 03:39:46 | 只看该作者
全局:
  1. import java.util.*;
  2. public class ParseCPULogFile {
  3.    
  4.         Stack<jobInformation> stack = new Stack<jobInformation>();
  5.         //the key is the name of the job, and the list of the interval is the list of job time
  6.         Map<String, List<interval>> map = new HashMap<String, List<interval>>();
  7.         String currentJobName = "";
  8.         int startTime = 0;
  9.         public void add(String jobName, boolean start, int timeStamp){
  10.                 if(start){
  11.                         //stack is null push into stack. cut the original job
  12.                         if(stack.isEmpty()){
  13.                             startTime = timeStamp;
  14.                             currentJobName = jobName;
  15.                         }
  16.                         else{
  17.                                 if(currentJobName.equals(jobName)){
  18.                                     jobInformation job = new jobInformation(jobName, start, timeStamp);
  19.                                     stack.push(job);
  20.                                 }
  21.                                 else{
  22.                                         int endTimeStamp = stack.peek().timeStamp;
  23.                                         addToMap(stack.peek().jobName, startTime, endTimeStamp);
  24.                                     startTime = timeStamp;
  25.                                     currentJobName = jobName;
  26.                                 }
  27.                         }
  28.                     jobInformation job = new jobInformation(jobName, start, timeStamp);
  29.                     stack.push(job);
  30.                 }
  31.                 else{
  32.                 jobInformation originalJob= stack.pop();
  33.                 if(!stack.isEmpty() && stack.peek().jobName.equals(jobName)){
  34.                 }
  35.                 else{
  36.                         addToMap(jobName, startTime, timeStamp);
  37.                         if(!stack.isEmpty()){
  38.                                 currentJobName = stack.peek().jobName;
  39.                                 startTime = stack.peek().timeStamp;
  40.                         }
  41.                 }
  42.                 }
  43.         }
  44.         //print out the result
  45.        
  46.         public void addToMap(String jobName, int start, int end){
  47.                 interval newInterval = new interval(startTime, end);
  48.             if(!map.containsKey(jobName)){
  49.                List<interval> list = new LinkedList<interval>();
  50.                map.put(jobName, list);
  51.             }
  52.             map.get(jobName).add(newInterval);
  53.         }
  54.        
  55.         public String output(){
  56.                 return "";
  57.                 //for loop the print all the jobs.
  58.                 //print out all the jobs. So I have twenty five minutes to try the tackle with the proramming question, 10 minutes to deal with the fllow up question
  59.         }
  60.        
  61.         //build the class to store the interval
  62.         public class interval{
  63.                 int start;
  64.                 int end;
  65.                 interval(int start, int end){
  66.                         this.start = start;
  67.                         this.end = end;
  68.                 }
  69.         }
  70.         //build the jobInformation class
  71.         public class jobInformation{
  72.                 String jobName;
  73.                 boolean start;
  74.                 int timeStamp;
  75.                 jobInformation(String jobName, boolean start, int timeStamp){
  76.                         this.jobName = jobName;
  77.                         this.start = start;
  78.                         this.timeStamp = timeStamp;
  79.                 }
  80.         }
  81. }
复制代码
回复

使用道具 举报

🔗
fantasiasango 2016-9-24 03:24:33 | 只看该作者
全局:
感谢分享! 今天发米上限了。。
回复

使用道具 举报

🔗
 楼主| abcd1992719g 2016-10-3 00:23:06 | 只看该作者
全局:
pawprinter 发表于 2016-9-5 03:13
多谢,请问您onsite了吗

嗯 周一出结果
回复

使用道具 举报

🔗
 楼主| abcd1992719g 2016-10-3 00:23:18 | 只看该作者
全局:
fantasiasango 发表于 2016-9-24 03:24
感谢分享! 今天发米上限了。。

哈哈 ~~~~~~~
回复

使用道具 举报

🔗
pawprinter 2016-10-3 02:40:32 | 只看该作者
全局:

祝福!求面经呀~~
回复

使用道具 举报

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

本版积分规则

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