腾讯存储工程师二面 面经

面试是腾讯文档里直接写的,没有测试过。题目是我脑补的。刚面完,不知道过了没。大家知道有几轮面试吗?

  1. Given the following linked list node structure, where “random” can point to any node of the linked list. Please write a function copyRandomList that replicates the original list and returns it.

    class Node {
    public:
     int val;
     Node* next;
     Node* random;
    
     Node(int _val) {
         val = _val;
         next = NULL;
         random = NULL;
     }
    };
    Node* copyRandomList(Node* head) {
     if(head == nullptr) return nullptr;
     Node* res = new Node(head->val);
     if(head->next == nullptr) {
         if(head->random == head) res->random = res;
         return res;
     }
     map<Node*, Node*> m;
     m.insert(make_pair(head, res));
     for(Node* n = head->next, p = res; n->next != nullptr; 
             n = n->next, p = p->next) {
         p->next = new Node(n->val);
         m.insert(make_pair(n, p->next));
     }
     for(Node* n = head, p = res; n->next != nullptr; 
             n = n->next, p = p->next) {
         auto iter = m.find(n);
         if(iter != m.end()) {
             p->random = iter->second;
         }
     }
     return res;
    }
  2. Given a regular binary TreeNode structure, please find the longest distance of the tree. For example, in the following tree, the longest length should be 3, which is from 2 to 4.

class TreeNode {
TreeNode* left;
TreeNode* right;
int val;
} 

int maxL = 0;
int dfs(TreeNode* root) 
{
    if(root == nullptr) return 0;
    int left = dfs(root->left);
    int right = dfs(root->right);
    int h = max(left, right) + 1;
    int l = left + right + 2;
    if(l > maxL) maxL = l;
        return h;
    }

int longestPath(TreeNode* root)
{
    dfs(root);
    return maxL;
}
  1. Some Concepts(中间大部分我都不知道,有点凉,后来面试官就不问概念性的了)
    short : url (like bit.ly)
    hashmap: concurrent hashmap
    compare and change (CAS)
    GAP锁
    MVVC
    事务?
    Transaction 隔离性级别
    rr 串行化
    Linux 4KB page, how to fit mysql 16KB page

  2. There is a 100-storey building, and you have two eggs. You want to know at which level of the building you throw the egg, will the egg be broken. But don’t know how hard the eggs are, so you have to experiment. How many trials do you have to make to find out the result?

面试官写的:(大概就只有一个鸡蛋需要100次,如果有两个呢?)
100 层
1 个 100次
2 个
10

比较巧,我一开始说如果分成10段,一段段弄过去,最多就20次,后来面试官问最少需要多少次,列个式子,正好也是20次(大概20次,实际边界上应该不用验证)。

100 / n + n >= 20

#面经#
全部评论
今天发现,凉了,校园招聘那里变灰了。
点赞 回复 分享
发布于 2020-09-01 23:14
楼主你好,请问你是实习、校招还是社招
点赞 回复 分享
发布于 2020-08-05 13:45
这里编辑起来挺麻烦的,indentaion我就不管了😂
点赞 回复 分享
发布于 2020-08-04 22:06

相关推荐

已oc&nbsp;云智断更了好几天,也有一些话想说,继续更新一篇云智timeline&nbsp;4.18&nbsp;一面&nbsp;半个小时后约二面&nbsp;4.21二面&nbsp;当晚&nbsp;约hr面&nbsp;4.23hr面&nbsp;4.30&nbsp;发offer之前美团的二面挂了,进入人才库,后面又被捞起来面试,4.30号&nbsp;美团又一面,现在还没出一面结果感觉也不报什么希望,就算一面过了,还有二面,我经不起深入拷打,唉,真的,好难五一躺平了五天,吃吃玩玩睡睡~还要担心毕业,科研更是难,唉暑期可能就到此为止了,后面没有时间在这个上面了,要抓紧时间做科研,为了后面能出去实习。大厂,秋招再见!!!有一些感慨:4.1是我的第一次面试,美团,面试的时候紧张到浑身发...
daisy9542:我今晚也是美团一面,已经第六次了。我也面了其他的,没拿到 offer。但我想开了,要按照自己的节奏来,找暑期转正然后秋招大杀四方并不是唯一的出路,其实还有很多选择的,有 0 实习最后秋招拿 offer 了,也有不选择互联网去国企的外企的,考编的,创业的。现在的失败不代表以后的路都是黑暗的,只不过可能运气还没降临到头上。所以现在要做的,就是放平心态,提升自己,通过面试了解到自己的优点和不足,争取下次机会来了能好好抓住
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
2
分享

创作者周榜

更多
牛客网
牛客企业服务