📣 黑五价提前开抢|VIP一年通行证5折,蓝莓、Offer多多同步特惠
回复: 5
跳转到指定楼层
上一主题 下一主题
收起左侧

第二轮OA乙烷,哭瞎了

全局:

2016(1-3月) 码农类General 硕士 实习@fidessa - 网上海投 - 在线笔试  | | Other | 其他

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

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

x
第二轮OA一共四道题,两道编程两道Code Review。。。编程题第一题是找一个序列之内最大一个的matching的位置,
具体规则如下
1. 序列首字母必须是大写,否则返回-1,
2.如果一个大写字母后面还是大写字母,那么继续往后找。
3.如果一个大写字母后面紧跟着自己的小写字母,这两个字母就degrade掉,就跟zuma一样,一大写一小
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
order="0" alt="" />

评分

参与人数 2大米 +43 收起 理由
霸王 + 3 感谢分享!
夏虫不知雪花 + 40

查看全部评分


上一篇:FB intern 电面, 攒人品
下一篇:万年不换题的LiveRamp OA
全局:
大年30是明天!!
回复

使用道具 举报

🔗
霸王 2016-2-7 09:21:42 | 只看该作者
全局:
失败是成功他妈!新的一年会顺利的~新年快乐。
回复

使用道具 举报

🔗
zhangbo0216 2016-2-27 01:01:07 | 只看该作者
全局:
楼主问下第二题两个链表一开始都是无序的嘛? 所以还要排序?
回复

使用道具 举报

🔗
chris-sun 2016-7-19 06:06:24 | 只看该作者
全局:
大概 写了一下 第二题 很low 的办法 思路 和leetcode 328 类似
  1. #include <iostream>
  2. #include <string>
  3. #include <stack>
  4. using namespace std;
  5. struct node{
  6.         string val;
  7.         node *next;
  8.         node(string x): val(x), next(nullptr){};
  9. };

  10. node* merge(node *n1, node *n2){
  11.         node *Rhead = new node("1");
  12.         node *Ohead = new node("1");
  13.         node *Yhead = new node("1");
  14.         node *Ghead = new node("1");
  15.         node *Bhead = new node("1");
  16.         node *Ihead = new node("1");
  17.         node *Vhead = new node("1");

  18.         node *Rcur = Rhead;
  19.         node *Ocur = Ohead;
  20.         node *Ycur = Yhead;
  21.         node *Gcur = Ghead;
  22.         node *Bcur = Bhead;
  23.         node *Icur = Ihead;
  24.         node *Vcur = Ihead;

  25.         node *cur = n1;
  26.        
  27.         while(cur != nullptr){
  28.                 node *tmp = cur;
  29.                 cur = cur -> next;
  30.                 tmp -> next = nullptr;
  31.                
  32.                 if(tmp -> val == "red") {Rcur -> next = tmp; Rcur = Rcur -> next; }
  33.                 else if(tmp -> val == "orange") {Ocur -> next = tmp; Ocur = Ocur -> next;}
  34.                 else if(tmp -> val == "yellow") {Ycur -> next = tmp; Ycur = Ycur -> next;}
  35.                 else if(tmp -> val == "green") {Gcur -> next = tmp; Gcur = Gcur -> next; }
  36.                 else if(tmp -> val == "blue") {Bhead -> next = tmp; Bhead = Bhead -> next;}
  37.                 else if(tmp -> val == "indigo") {Ihead -> next = tmp; Ihead = Ihead -> next;}
  38.                 else if (tmp -> val == "violet") {Vhead -> next = tmp; Vhead = Vhead -> next;}

  39.         }

  40.         cur = n2;

  41.         while(cur != nullptr){
  42.                 node *tmp = cur;
  43.                 cur = cur -> next;
  44.                 tmp -> next = nullptr;
  45.                
  46.                 if(tmp -> val == "red") {Rcur -> next = tmp; Rcur = Rcur -> next; }
  47.                 else if(tmp -> val == "orange") {Ocur -> next = tmp; Ocur = Ocur -> next;}
  48.                 else if(tmp -> val == "yellow") {Ycur -> next = tmp; Ycur = Ycur -> next;}
  49.                 else if(tmp -> val == "green") {Gcur -> next = tmp; Gcur = Gcur -> next; }
  50.                 else if(tmp -> val == "blue") {Bhead -> next = tmp; Bhead = Bhead -> next;}
  51.                 else if(tmp -> val == "indigo") {Ihead -> next = tmp; Ihead = Ihead -> next;}
  52.                 else if (tmp -> val == "violet") {Vhead -> next = tmp; Vhead = Vhead -> next;}
  53.         }
  54.        

  55.         node *res = new node("head");
  56.         cur = res;
  57.         if(Rhead -> next){
  58.                 cur -> next = Rhead -> next;
  59.                 cur = Rcur;
  60.         }

  61.         if(Ohead -> next){
  62.                 cur -> next = Ohead -> next;
  63.                 cur = Ocur;
  64.         }

  65.         if(Yhead -> next){
  66.                 cur -> next = Yhead -> next;
  67.                 cur = Ycur;
  68.         }

  69.         if(Ghead -> next){
  70.                 cur -> next = Ghead -> next;
  71.                 cur = Gcur;
  72.         }

  73.         if(Bhead -> next){
  74.                 cur -> next = Bhead -> next;
  75.                 cur = Bcur;
  76.         }

  77.         if(Ihead -> next){
  78.                 cur -> next = Ihead -> next;
  79.                 cur = Icur;
  80.         }

  81.         if(Vhead -> next){
  82.                 cur -> next = Vhead -> next;
  83.                 cur = Vcur;
  84.         }
  85.        
  86.         return res -> next;

  87. }

  88. int main(){
  89.         node *n1 = new node("red");
  90.         node *n2 = new node("green");
  91.         node *n3 = new node("yellow");
  92.         node *n4 = new node("red");
  93.         n1 -> next = n2; n2->next = n3; n3 -> next = n4;


  94.         node *n5 = new node("blue");
  95.         node *n6 = new node("red");
  96.         node *n7 = new node("indigo");
  97.         node *n8 = new node("green");
  98.         node *n9 = new node("orange");
  99.         n5 -> next = n6; n6 -> next = n7; n7 -> next = n8; n8 -> next = n9;

  100.         cout << "********** in program ********"<<endl;
  101.         node *res = merge(n1, n2);
  102.         while(res != nullptr){
  103.                 cout << res -> val << endl;
  104.                 res = res -> next;
  105.         }
  106.         //cout << res -> val <<endl;

  107. }
复制代码
回复

使用道具 举报

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

本版积分规则

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