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

领英 店面 Data Infra组

全局:

2016(10-12月) 码农类General 硕士 全职@linkedin - Other - 技术电面  | | Pass | 在职跳槽

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

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

x
不久前刚面的linkedin,由于对data方面感兴趣,被安排面的data infra组,回馈地里
是一个国人大哥面的
1.有cache有database的系统,你会如何执行写操作?
其实我也没有系统的学过这些东西,大概知道现在cache里开辟一个block,写满了在flush到database里,不过国人大哥更想听到的是对不同方法之间的利弊权衡,另一种是write through,写cache的同时写database,这种方法会慢,但是保证了consistency,突然崩了也可以恢复数据,distributed system里面也比较容易access data,否则cache也不好share
2. Java里final,finally, finallize分别解释, cc150有详细介绍
3.超水的算法题
// input contains only a-z
// return a string sorted in alphabetically
// input: zhcbca  output: abcchz
String sortString(String input) {
    if (input==null || input.length() <= 1) return input;
    int[] count = new int[26];
    for (int i=0; i<input.length(); i++) {
        count[input.charAt(i)-'a']++;
    }
    StringBuilder sb = new StringBuilder();
    for (char c='a'; c <='z'; c++) {
        if (count[c-'a']==0) continue;
        for (int j = 0; j<count[c-'a']; j++)
            sb.append(c);
    }
    return sb.toString();
}


4.design blockedQueue (忽略注释,注释是国人大哥后来讨论如何优化的时候写的)
public interface BlockedQueue <T> {
  BlockedQueue(int capacity);
  void put(T data);
  T poll();
}

public class myBlockedQueue <T> implements BlockedQueue {
    private Queue<T> myQueue;
    private int capacity = 20;

    public myBlockedQueue(int capacity) {
        myQueue = new LinkedList<>();
        this.capacity = capacity;
    }

    public synchronized void put (T data)
            throws InterruptedException{
        while (myQueue.size() == capacity) {
            wait();  // this.wait();
        }

        myQueue.offer(data);
        notifyAll();  // this.notifyAll(); notify one of threads blocked at poll();
    }

    public synchronized T poll()
            throws InterruptedException {
        while (myQueue.size() == 0) {
            wait();  // this.wait();
        }

        T data = myQueue.poll();
        notifyAll();  // this.notifyAll();  notify one of threads blocked at put();

        return data;
    }
}

评分

参与人数 1大米 +60 收起 理由
zj45499 + 60

查看全部评分


上一篇:巨硬 onsite 挂
下一篇:Facebook Intern 电面面经
🔗
honghunan 2016-11-13 10:54:32 | 只看该作者
全局:
谢谢楼主的答案!你这个写的很不错!
回复

使用道具 举报

🔗
say543 2016-11-13 15:25:16 | 只看该作者
全局:
楼主有被要求要时间 能够多个put or get吗 ? 像semahpore?
回复

使用道具 举报

🔗
 楼主| 清华金丝栗 2016-11-14 03:03:58 | 只看该作者
全局:
say543 发表于 2016-11-13 15:25
楼主有被要求要时间 能够多个put or get吗 ? 像semahpore?

没有,店面的时间估计来不及,加聊天还问了那么多道题,但是我估计要是去onsite,肯定会一直follow up一直改的,当时他只是跟我讨论了一下我的版本还有哪些问题,其实我对multi-threading都不熟,算是蒙过关了
回复

使用道具 举报

全局:
清华金丝栗 发表于 2016-11-14 03:03
没有,店面的时间估计来不及,加聊天还问了那么多道题,但是我估计要是去onsite,肯定会一直follow up一 ...

楼主,我也对multi-threading不熟。想问一下你, 比方说你这个例子。 如何按照面试官的注释里面的要求只notify一个thread呢? 多谢
回复

使用道具 举报

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

本版积分规则

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