12
返回列表 发新帖
楼主: 面假空虚
跳转到指定楼层
上一主题 下一主题
收起左侧

Google On Campus 面经

🔗
 楼主| 面假空虚 2015-11-7 05:55:17 | 只看该作者
全局:
感谢各位加米的盆友!!!
回复

使用道具 举报

🔗
 楼主| 面假空虚 2015-11-25 08:20:52 | 只看该作者
全局:
宝贝忆彼岸 发表于 2015-11-7 04:09
我还没去,下下周呢,我拖了好久的说。。。。捂脸。。。现在好怕没坑了

你Google现在什么情况啦
回复

使用道具 举报

🔗
lcl3356897 2015-11-25 08:33:53 | 只看该作者
本楼:
全局:
跪拜!!
回复

使用道具 举报

🔗
bobzhang2004 2015-12-3 04:16:06 | 只看该作者
全局:
第一轮第二题是用HashMap<key, BST>吗?, 第二轮是要用array实现minheap?
回复

使用道具 举报

🔗
 楼主| 面假空虚 2015-12-3 06:14:21 | 只看该作者
全局:
bobzhang2004 发表于 2015-12-3 04:16
第一轮第二题是用HashMap吗?, 第二轮是要用array实现minheap?

1. 嗯,就是那样,然后我偷了个懒里头的BST直接用现成的TreeSet了
2. 是用array搞minheap
回复

使用道具 举报

🔗
bobzhang2004 2015-12-3 06:20:56 | 只看该作者
全局:
面假空虚 发表于 2015-12-3 06:14
1. 嗯,就是那样,然后我偷了个懒里头的BST直接用现成的TreeSet了
2. 是用array搞minheap

有点难啊,楼主厉害!

补充内容 (2015-12-3 06:27):
是Treemap吧?
回复

使用道具 举报

🔗
 楼主| 面假空虚 2015-12-3 08:33:21 | 只看该作者
全局:
bobzhang2004 发表于 2015-12-3 06:20
有点难啊,楼主厉害!

补充内容 (2015-12-3 06:27):

嗯是TreeMap,然后index做key就好了。太久没看这个随手写了个TreeSet不好意思
回复

使用道具 举报

🔗
bobzhang2004 2015-12-3 23:10:14 | 只看该作者
全局:
第一题代码,如果可以用treemap的话代码其实不长
  1. public class DataStructureKeyIndexValue {

  2.         HashMap<Integer, TreeMap<Integer, Integer>> map;
  3.         public DataStructureKeyIndexValue() {
  4.                 map = new HashMap<Integer, TreeMap<Integer, Integer>>();
  5.         }
  6.         public void put(int key, int index, int value) {
  7.                 if (map.containsKey(key)) {
  8.                         map.get(key).put(index, value);
  9.                 }  else {
  10.                         TreeMap<Integer, Integer> treeMap = new TreeMap<Integer, Integer>();
  11.                         treeMap.put(index, value);
  12.                         System.out.println(treeMap.containsKey(index));
  13.                         map.put(key, treeMap);
  14.                 }
  15.         }
  16.        
  17.         public int get(int key, int index) throws Exception  {
  18.                 if (map.containsKey(key) && map.get(key).containsKey(index)) {
  19.                         return map.get(key).get(index);
  20.                 } else {
  21.                         throw new Exception();
  22.                 }
  23.         }
  24.        
  25.        
  26.         public static void main(String[] args) throws Exception {
  27.                 DataStructureKeyIndexValue ds = new DataStructureKeyIndexValue();
  28.                 ds.put(1, 2, 9);
  29.                 ds.put(1, 3, 8);
  30.                 ds.put(2, 1, 9);
  31.                 System.out.println(ds.get(1, 2));
  32.                 System.out.println(ds.get(1, 3));
  33.                 System.out.println(ds.get(2, 1));
  34.         }
  35. }
复制代码
回复

使用道具 举报

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

本版积分规则

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