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

Google New Grad 电面

 
🔗
hhhyyy 2017-9-29 05:18:17 | 只看该作者
全局:
请问楼主,第一题判断a,b是不是只有一个insertion的区别有没有比O(n)更优的解法啊?
回复

使用道具 举报

🔗
lizhecoder 2017-9-29 11:48:48 | 只看该作者
全局:
10分钟能写完,狠
回复

使用道具 举报

🔗
J.J.Thomson 2017-10-5 02:50:39 | 只看该作者
全局:
我是撸主迷妹,希望能顺利offer!
回复

使用道具 举报

🔗
zoeymiao 2017-10-5 09:00:11 | 只看该作者
本楼:
全局:
楼主厉害!
回复

使用道具 举报

🔗
vodkabuaa 2017-10-8 05:09:27 | 只看该作者
全局:
想问下楼主第一题是用暴力解法吗?
回复

使用道具 举报

🔗
renhh 2017-10-9 22:27:22 | 只看该作者
全局:
写了一个backtracking的代码,过了一个简单的testcase,想要的可以留言
回复

使用道具 举报

🔗
czy2105636 2017-10-10 07:16:10 | 只看该作者
全局:
感谢楼主分享
回复

使用道具 举报

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

使用道具 举报

🔗
gfgfgf 2017-10-10 21:18:10 | 只看该作者
全局:
请问楼主oa结束什么等了多久收到电面的消息?
回复

使用道具 举报

🔗
renhh 2017-10-12 07:03:26 | 只看该作者
全局:
感觉写的比较笨。。
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>

  4. using namespace std;

  5. vector<vector<string>> res;
  6. vector<string> candidate{""};
  7. map<int, vector<string>> wordmap;

  8. bool isContain(string a, string b){
  9.     if(b==""){
  10.         return true;
  11.     }
  12.     for(unsigned int i=0;i<a.size();i++){
  13.         string newa = a;
  14.         newa.erase(newa.begin()+i);
  15.         if(newa==b){
  16.             return true;
  17.         }
  18.     }
  19.     return false;
  20. }

  21. void help( map<int, vector<string>> &wordmap, int startlength, vector<vector<string>> &res,vector<string> &candidate){
  22.     if(wordmap.find(startlength)==wordmap.end()){
  23.         res.push_back(candidate);
  24.         return;
  25.     }
  26.     for(unsigned int i=0;i<wordmap[startlength].size();i++){
  27.         if(isContain(wordmap[startlength][i],candidate.back())){
  28.             candidate.push_back(wordmap[startlength][i]);
  29.             help(wordmap,startlength+1,res,candidate);
  30.             candidate.pop_back();
  31.         }
  32.     }
  33. }

  34. string longestlist(vector<string> words){
  35.    //find the map of word length
  36.    for(unsigned int i=0;i<words.size();i++){
  37.         wordmap[words[i].size()].push_back(words[i]);
  38.     }
  39.     help(wordmap,1,res,candidate);
  40.     int longestindex=0;
  41.     int longestlength=0;
  42.     for(unsigned int i=0;i<res.size();i++){
  43.         if(res[i].back().size()>longestlength){
  44.             longestindex=i;
  45.             longestlength = res[i].back().size();
  46.         }
  47.     }
  48.     return res[longestindex].back();
  49. }


  50. int main ()
  51. {
  52.     vector<string> words{"a","ac","abdet","afc","abrdet","ab","abd","abde"};
  53.     string res = longestlist(words);
  54.     return 0;
  55. }
复制代码
回复

使用道具 举报

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

本版积分规则

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