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

dropbox电面合集

全局:

2016(4-6月) 码农类General 硕士 全职@dropbox - 内推 - 技术电面  | | Fail | 应届毕业生

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

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

x
已经挂了 被面试官怀疑见过原题 发上来我准备的面经合集 为后面的onsite攒攒人品

  • 1. Hit counter



#include<queue>
#include<iostream>
#include<mutex>
using namespace std;

class HitCounter{
private:
        mutex l;
        queue<int> q;
public:
        HitCounter(){}
        void hit(int t) {
                l.lock();
                q.push(t);
                l.unlock();
        }
        int getHit(int timestamp) {
                l.lock();       
                while(!q.empty() && timestamp - q.front() >= 300) {
                        q.pop();
                }
                l.unlock();
                return q.size();
        }
};

int main() {
        HitCounter h1;
        h1.hit(1);
        h1.hit(2);
        h1.hit(3);
        h1.hit(300);
        cout << h1.getHit(300) << endl;
//        h1.hit(301);
        cout << h1.getHit(301) << endl;
}
..








2. word pattern

class Solution {
public:
    bool wordPattern(string pattern, string str) {
        stringstream ss(str);
        string s;
        int count = 0;
        unordered_map<string, char> map1;
        unordered_map<char, string> map2;
        while(ss >> s) {
            if(count >= pattern.size())
                return false;
            if(map1.find(s) == map1.end()) {
                map1 = pattern[count];
            }
            else {
                if(map1 != pattern[count])
                    return false;
            }
            if(map2.find(pattern[count]) == map2.end()) {
                map2[pattern[count]] = s;
            }
            else{
                if(map2[pattern[count]] != s)
                    return false;
            }
            count++;
        }
        if(count < pattern.size())
            return false;
        else
            return true;
    }
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
s;
        int interval = min(1000, size - start);
        unordered_map<int, vector<string>> m;
        if(start >= size)
                return {value};
        for(int i = 0; i < value.size(); i++) {
                int hash_key = get_hash(value[i], start, interval);
                m[hash_key].push_back(value[i]);
        }
        if(m.size() == value.size())
                return res;
        for(auto t = m.begin(); t != m.end(); t++) {
                if(t->second.size() > 1) {
                        vector<vector<string>> vec = find_same_file(it->second, start + interval, size);
                        res.insert(res.end(), vec.begin(), vec.end());
                }
        }
        return res;
}
vector<vector<string>> find_dul_files(string input) {
        vector<string> files = find_all_files(input);
        vector<vector<string>> res;
        unordered_map<int, vector<string>> map;
        for(int i = 0; i < files.size(); i++) {
                map[get_size(files[i])].push_back(files[i])
        }
        for(auto it = map.begin(); it != map.end(); it++) {
                if((it->second).size() > 1) {
                        vector<vector<string>> tmp_res = find_same_file(it->second, 0, it->first);
                        res.insert(res.end(), tmp_res.begin(), tmp_res.end());
                }
        }
        return res;
       
}





评分

参与人数 7大米 +115 收起 理由
fanghao + 10 给你点个赞!
忆梦前尘 + 25 很有用的信息!
kdzhang + 1 很有用的信息!
allenxn24 + 3 感谢分享!
fflute + 3 谢谢你的介绍!

查看全部评分


上一篇:求亚麻群面面经题
下一篇:有关Amazon OA1的问题
🔗
jigsaw_Becky 2016-11-7 03:50:06 | 只看该作者
全局:
面试官是觉得你答的太好了么?
回复

使用道具 举报

🔗
Crazy_fight 2016-11-13 15:18:58 | 只看该作者
全局:
楼主一轮答了这么多?
回复

使用道具 举报

🔗
ShiqiFight 2018-6-7 09:45:19 | 只看该作者
本楼:
全局:
感谢楼主!!!
回复

使用道具 举报

🔗
candicedjy 2018-6-11 11:33:55 | 只看该作者
全局:
为什么代码都是有一条横线的。。。
回复

使用道具 举报

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

本版积分规则

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