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

Qumulo Phone Interview

全局:

2016(1-3月) 码农类General 硕士 全职@qumulo - 网上海投 - 技术电面  | | Fail | 应届毕业生

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

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

x
今天结束了Qumulo,地里好像没有出现过这题,来贡献一下跪经。。。
给两个list of integers,求这两个list的intersection。

比方说:
[4, 2, 1, 9, 8]
[1, 3
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
ystem.out.println(it.next());


就会依次输出: 1, 8

我手忙脚乱写了一个buggy版本。。。最后时间不够了

评分

参与人数 1大米 +3 收起 理由
benjaminxu + 3 感谢分享!

查看全部评分


上一篇:求教老司机, amazon给了个onsite是什么意思?
下一篇:1.26面完亚麻video,现在还没消息,有点心慌
推荐
hotinherre 2016-2-17 13:49:19 | 只看该作者
全局:
  1. public class IntersectionIterator{
  2.         int nextNum;   // record the number of the next iterator
  3.         boolean callHasNext; // check if call hasNext function before calling next function
  4.         Iterator itr1;
  5.         Iterator itr2;
  6.        
  7.         public IntersectionIterator(Iterator itr1, Iterator itr2){
  8.                 this.itr1 = itr1;  //Iterator itr = list.Iterator();
  9.                 this.itr2 = itr2;
  10.         }

  11.         // check if hasNext, and update the nextNum
  12.         public boolean hasNext(){
  13.                 if(!itr1.hasNext() || !itr2.hasNext()) return false;
  14.                 int num1 = itr1.next();
  15.                 int num2 = itr2.next();
  16.                 // keep move two iterator, until two numers are same or one of the iterator doesn't have next number.
  17.                 while(true){
  18.                         if(num1 == num2){
  19.                                 nextNum = num1;
  20.                                 return true;
  21.                         }
  22.                         // move the iterator of the smaller number forward
  23.                         else if(num1 < num2){
  24.                                 if(!itr1.hasNext()) return false;
  25.                                 num1 = itr1.next();
  26.                         }
  27.                         else{
  28.                                 if(!itr2.hasNext()) return false;
  29.                                 num2 = itr2.next();
  30.                         }
  31.                 }
  32.         }

  33.         public int next(){
  34.                 if(!callHasNext){
  35.                         // if user call next funtion but no more intersection number
  36.                         if(!hasNext()){
  37.                                 System.out.println("No more intersection number!");
  38.                                 return Integer.MIN_VALUE;
  39.                         }
  40.                         else{
  41.                                 callHasNext = false; //reset the callHasNext
  42.                                 return nextNum;
  43.                         }
  44.                 }
  45.                 else{
  46.                         callHasNext = false; // reset
  47.                         return nextNum;
  48.                 }
  49.         }
  50. }
复制代码
Iterator 的代码我写了一下, 大家看看对不对

回复

使用道具 举报

推荐
aifer 2016-2-22 06:49:33 | 只看该作者
全局:
给一个我写的例子吧。
  1. public class IntersectionIterator implements Iterator<Integer>{

  2.         private Iterator<Integer> iter1;
  3.         private Iterator<Integer> iter2;
  4.         private Integer item;        // cache the number appeared in both lists
  5.        
  6.         public IntersectionIterator(Iterator<Integer> a, Iterator<Integer> b){
  7.                 iter1 = a;
  8.                 iter2 = b;
  9.                 item = null;
  10.                 cacheNext();
  11.         }

  12.         @Override
  13.         public boolean hasNext() {
  14.                 return item != null;
  15.         }

  16.         @Override
  17.         public Integer next() {
  18.                 Integer cur = item;
  19.                 item = null;
  20.                 cacheNext();
  21.                 return cur;
  22.         }
  23.        
  24.         /*
  25.          * cache number appeared in both lists.
  26.          */
  27.         private void cacheNext(){
  28.                 if(iter1.hasNext() && iter2.hasNext()){
  29.                         Integer x = iter1.next();
  30.                         Integer y = iter2.next();
  31.                         while(x!= null && y != null && x != y) {
  32.                                 if(x < y && iter1.hasNext()) x = iter1.next();
  33.                                 else if(x < y) x = null;
  34.                                 else if(x > y && iter2.hasNext()) y = iter2.next();
  35.                                 else if( x> y) y = null;
  36.                         }
  37.                         // find the first repeated number and cache it.
  38.                         if(x != null && y != null && x.equals(y)) item = x;
  39.                 }
  40.         }
  41. }
复制代码
回复

使用道具 举报

🔗
hotinherre 2016-2-5 13:32:43 | 只看该作者
全局:
看来qumolo面试真的 不简单啊。。。 谢谢楼主分享了! 我是投实习的 但是给的我也是全职的oa 说实习全职一样对待。。  对了 你是直接开始做题么? 多久的面试?
回复

使用道具 举报

🔗
 楼主| hercule24 2016-2-5 13:45:15 | 只看该作者
全局:
hotinherre 发表于 2016-2-5 13:32
看来qumolo面试真的 不简单啊。。。 谢谢楼主分享了! 我是投实习的 但是给的我也是全职的oa 说实习全职一 ...

我提前把网上那四道OA题做了再去的 都有快一个月了吧
回复

使用道具 举报

🔗
starfalling 2016-2-5 13:51:05 | 只看该作者
全局:
这是家神奇的小公司,看到glassdoor上面一排跪经https://www.glassdoor.com/Interview/Qumulo-Interview-Questions-E678884.htm。package挺给力的貌似。
回复

使用道具 举报

🔗
 楼主| hercule24 2016-2-6 00:17:34 | 只看该作者
全局:
starfalling 发表于 2016-2-5 13:51
这是家神奇的小公司,看到glassdoor上面一排跪经https://www.glassdoor.com/Interview/Qumulo-Int ...

所以进去应该很难吧
回复

使用道具 举报

🔗
starfalling 2016-2-6 04:39:30 | 只看该作者
全局:
hercule24 发表于 2016-2-6 00:17
所以进去应该很难吧

感觉应该挺难的,主要是规模小不怎么招人。然后package又给力,就更难进了。
回复

使用道具 举报

🔗
blactangeri 2016-2-7 10:46:12 | 只看该作者
全局:
请问lz
第二问怎么做的谢谢

评分

参与人数 1大米 +3 收起 理由
zsmj001 + 3 欢迎来一亩三分地论坛!

查看全部评分

回复

使用道具 举报

🔗
 楼主| hercule24 2016-2-7 12:35:38 | 只看该作者
全局:
blactangeri 发表于 2016-2-7 10:46
请问lz
第二问怎么做的谢谢

第二题也是sorted的,所以也是按照当前两个iterator指向的值比较,向前移动小的那个的iterator
回复

使用道具 举报

🔗
丢丢棠线 2016-2-17 02:36:36 | 只看该作者
全局:
hercule24 发表于 2016-2-7 12:35
第二题也是sorted的,所以也是按照当前两个iterator指向的值比较,向前移动小的那个的iterator

楼主 请问一下 第二问的意思是
public IntersectionIterator findIntersection(Iterator i1,Iretator i2){
}
这样子么?
我不太懂 多谢多谢
回复

使用道具 举报

🔗
 楼主| hercule24 2016-2-17 02:49:13 | 只看该作者
全局:
丢丢棠线 发表于 2016-2-17 02:36
楼主 请问一下 第二问的意思是
public IntersectionIterator findIntersection(Iterator i1,Iretator i2 ...

应该是 IntersectionIterator (Iterator i1,Iretator i2) {
}
这样子的吧,这样子就是实现一个类了
回复

使用道具 举报

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

本版积分规则

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