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

g家实习电面跪经

全局:

2016(1-3月) 码农类General 硕士 实习@google - 内推 - 技术电面  | | Other | 应届毕业生

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

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

x
昨天的实习电面
第一个看名字是个白人,目是这样
Given a class IntSetIter with mothods “hasNext()” and“next()”, implement a class UnionSetIter that takes into two IntSetIter’s andproduce a new IntSetIter
我看看了挺久的,然后可以 一开始把两个<
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
e="宋体">题
followup是如果把A大写,所有的A都要大写
我用backtracking写的,小哥人很nice,提示下修了不少bug,还问了时间复杂度。followup写完,小哥说还可以优化,但是没时间了,就结束了。

目测已跪,发面经攒rp吧

评分

参与人数 1大米 +80 收起 理由
zzwcsong + 80

查看全部评分


上一篇:Yelp on campus + onsite 面经
下一篇:Bloomberg水过店面
全局:
写了个代码,应该还能优化。

  1.         public static Set<String> generateBig(String input,Set<Character> set)
  2.         {
  3.                 Set<String> st = new HashSet<String>();
  4.                 String tempStr = input;
  5.                 helperGenerator(st, tempStr,input,0,set);
  6.                
  7.                  return st;
  8.         }
  9.        
  10.         public static void helperGenerator(Set<String> res, String sb, String word, int index,Set<Character> set)
  11.         {   


  12.                         Iterator<Character> itr = set.iterator();
  13.                        
  14.                         while(itr.hasNext())
  15.                         {
  16.                                 char temp = itr.next();

  17.                                 //"airplane"
  18.                                 for(int i = index; i < word.length();i++)
  19.                                 {
  20.                                 if(word.charAt(i)==temp)
  21.                                 {   
  22.                                     res.add(sb);
  23.                                         helperGenerator(res,sb,word,i+1,set);
  24.                                         StringBuilder sb1 = new StringBuilder(sb);
  25.                                         sb1.setCharAt(i,Character.toUpperCase(word.charAt(i)));
  26.                                     res.add(sb1.toString());
  27.                                         helperGenerator(res,sb1.toString(),word,i+1,set);
  28.                                        
  29.                                 }       
  30.                         }       
  31.                 }
  32.                 //sb.setLength(lengthTemp);
  33.         }

复制代码
回复

使用道具 举报

全局:
lz, set 是排好序的么?

补充内容 (2016-2-18 06:12):
搞错了 不是说要返回两个set一样的值哈? 那道题的考点是什么? 需要顺序返回set的element么?
回复

使用道具 举报

全局:
muybienw 发表于 2016-3-6 03:52
第一题现在能想到的就是先不断next()第一个iterator,然后把读取过的数据记下来,然后在next()第二个iterat ...

follow up, 可以加一个map,来记录,
  1. public class CapitalAndLowercaseStringsII {

  2.         public static void main(String[] args) {
  3.                 Set<Character> set = new HashSet<Character>();
  4.                 set.add('a');
  5.                 set.add('p');
  6.                 List<String> res = generataAllStringFollowUp("airpalne", set);
  7.                 for (String s : res) {
  8.                         System.out.println(s);
  9.                 }
  10.         }

  11.         public static List<String> generataAllStringFollowUp(String input,
  12.                         Set<Character> set) {
  13.                 List<String> res = new ArrayList<String>();
  14.                 if (input == null || input.length() == 0) {
  15.                         return res;
  16.                 }
  17.                 HashMap<Character, Character> map = new HashMap<Character, Character>();
  18.                 helper(res, new StringBuilder(), set, input, 0, map);
  19.                 return res;
  20.         }

  21.         public static void helper(List<String> res, StringBuilder sb,
  22.                         Set<Character> set, String input, int pos,
  23.                         HashMap<Character, Character> map) {
  24.                 if (pos == input.length()) {
  25.                         res.add(sb.toString());
  26.                         return;
  27.                 }
  28.                 char c = input.charAt(pos);
  29.                 if (!set.contains(c)) {
  30.                         sb.append(c);
  31.                         helper(res, sb, set, input, pos + 1, map);
  32.                         sb.deleteCharAt(sb.length() - 1);
  33.                 } else {
  34.                         if (map.containsKey(c)) {
  35.                                 char ch = map.get(c);
  36.                                 sb.append(ch);
  37.                                 helper(res, sb, set, input, pos + 1, map);
  38.                                 sb.deleteCharAt(sb.length() - 1);
  39.                         } else {
  40.                                 sb.append(c);
  41.                                 map.put(c, c);
  42.                                 helper(res, sb, set, input, pos + 1, map);
  43.                                 sb.deleteCharAt(sb.length() - 1);
  44.                                 map.remove(c);
  45.                                 char capital = (char) (c - 'a' + 'A');
  46.                                 map.put(c, capital);
  47.                                 sb.append(capital);
  48.                                 helper(res, sb, set, input, pos + 1, map);
  49.                                 sb.deleteCharAt(sb.length() - 1);
  50.                                 map.remove(c);
  51.                         }
  52.                 }
  53.         }
  54. }
复制代码
回复

使用道具 举报

🔗
 楼主| tjnkzll 2016-2-18 06:39:50 | 只看该作者
全局:
set是无序的,可随意返回值,但是不能有duplicate
回复

使用道具 举报

🔗
lxxxxxxx 2016-2-18 06:53:46 | 只看该作者
全局:
请问一下楼主第一题,可以拿一个HashSet把输出过的都加进去么....不然真想不到别的办法去重了......
回复

使用道具 举报

🔗
joana92 2016-2-18 06:56:34 | 只看该作者
全局:
谢谢楼主面经。楼主答的还不错啊。第二题 follow up 怎么优化呢?
回复

使用道具 举报

🔗
echo33 2016-2-18 07:36:02 | 只看该作者
全局:
第一题除非是sorted 否则不看整个set怎么可能判断?
回复

使用道具 举报

🔗
echo33 2016-2-18 07:39:29 | 只看该作者
全局:
echo33 发表于 2016-2-18 07:36
第一题除非是sorted 否则不看整个set怎么可能判断?

或者是不允许你construct new set但是可以读完其中一个set存储到hash table里?
回复

使用道具 举报

🔗
 楼主| tjnkzll 2016-2-18 07:48:56 | 只看该作者
全局:
echo33 发表于 2016-2-18 07:39
或者是不允许你construct new set但是可以读完其中一个set存储到hash table里?

可以construct new set,但是不能一次都读完
回复

使用道具 举报

🔗
 楼主| tjnkzll 2016-2-18 07:49:31 | 只看该作者
全局:
lxxxxxxx 发表于 2016-2-18 06:53
请问一下楼主第一题,可以拿一个HashSet把输出过的都加进去么....不然真想不到别的办法去重了......

可以的





回复

使用道具 举报

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

使用道具 举报

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

本版积分规则

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