~~收集的面经~~

1. 实现hashtable的put 和get操作

参考:https://yikun.github.io/2015/04/01/Java-HashMap%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86%E5%8F%8A%E5%AE%9E%E7%8E%B0/

put:

  1. 对key的hashCode()做hash,然后再计算index;
  2. 如果没碰撞直接放到bucket里;
  3. 如果碰撞了,以链表的形式存在buckets后;
  4. 如果碰撞导致链表过长(大于等于TREEIFY_THRESHOLD),就把链表转换成红黑树;
  5. 如果节点已经存在就替换old value(保证key的唯一性)
  6. 如果bucket满了(超过load factor*current capacity),就要resize

get:

  1. bucket里的第一个节点,直接命中;
  2. 如果有冲突,则通过key.equals(k)去查找对应的entry
    若为树,则在树中通过key.equals(k)查找,O(logn);
    若为链表,则在链表中通过key.equals(k)查找,O(n)

2. 给定一个8*8的棋盘,一个起始位置si,sj, 一个终止位置ei,ej,求问马从起始位置到终止位置最少需要多少步。

附:八皇后问题

https://blog.csdn.net/friendbkf/article/details/49892039

https://www.cnblogs.com/xinghuan/p/6061824.html

3. 给定一棵二叉树,求这颗二叉树最大子路径和,包括横跨根结点的路径

https://blog.csdn.net/feeltouch/article/details/78511214

public class Solution {

    private int max = Integer.MIN_VALUE;

    public int maxPathSum(TreeNode root) {
helper(root);
return max;
} public int helper(TreeNode root) {
if(root == null) return ;
int left = helper(root.left);
int right = helper(root.right);
//连接父节点的最大路径是一、二、四这三种情况的最大值
int currSum = Math.max(Math.max(left + root.val, right + root.val), root.val);
//当前节点的最大路径是一、二、三、四这四种情况的最大值
int currMax = Math.max(currSum, left + right + root.val);
//用当前最大来更新全局最大
max = Math.max(currMax, max);
return currSum;
}
}

4. 每k个反转单链表。

https://blog.csdn.net/beiyetengqing/article/details/7596707

public static Node reverse (Node head, int k) {
Node current = head;
Node next = null;
Node prev = null;
int count = ; /*reverse first k nodes of the linked list */
while (current != null && count < k) {
next = current.next;
current.next = prev;
prev = current;
current = next;
count++;
} /* next is now a pointer to (k+1)th node
Recursively call for the list starting from current.
And make rest of the list as next of first node */
if(next != null) {
head.next = reverse(next, k);
} /* prev is new head of the input list */
return prev;
}
Struct btree{

    Int value;

    Btree*l;

    Btree*r;

}

int maxn=-;

int find_max(Btree*root){

        if(!root)

            return ;

        int l = find_max(root->l)

        int r = find_max(root->r)

        int m = max(i,j)+root->value;

        int m2

        if(m>maxn)

              maxn=m;

        return m;  
}

【interview】Microsoft面经的更多相关文章

  1. Microsoft Interview第一轮

    上来随意交谈了一小会儿,开了点小玩笑,chat了一些关于他们recruter行程的话题,缓和了一下气氛. 进入正题,问了做的research的方向,我说是DLT,然后大概给他讲解了一下具体是什么, 跟 ...

  2. WCF学习系列二---【WCF Interview Questions – Part 2 翻译系列】

    http://www.topwcftutorials.net/2012/09/wcf-faqs-part2.html WCF Interview Questions – Part 2 This WCF ...

  3. WCF学习系列一【WCF Interview Questions-Part 1 翻译系列】

    http://www.topwcftutorials.net/2012/08/wcf-faqs-part1.html WCF Interview Questions – Part 1 This WCF ...

  4. [转]Design Pattern Interview Questions - Part 4

    Bridge Pattern, Composite Pattern, Decorator Pattern, Facade Pattern, COR Pattern, Proxy Pattern, te ...

  5. 8 TIPS TO BECOME A MICROSOFT TECHNICAL EVANGELIST

    8 TIPS TO BECOME A MICROSOFT TECHNICAL EVANGELIST By Thomas Lewis February, 28 2012 I have had a pai ...

  6. Google Interview University - 坚持完成这套学习手册,你就可以去 Google 面试了

    作者:Glowin链接:https://zhuanlan.zhihu.com/p/22881223来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 原文地址:Google ...

  7. 卷积神经网络和CIFAR-10:Yann LeCun专访 Convolutional Nets and CIFAR-10: An Interview with Yann LeCun

    Recently Kaggle hosted a competition on the CIFAR-10 dataset. The CIFAR-10 dataset consists of 60k 3 ...

  8. Install and run DB Query Analyzer 6.04 on Microsoft Windows 10

          Install and run DB Query Analyzer 6.04 on Microsoft Windows 10  DB Query Analyzer is presented ...

  9. Demonstration of DB Query Analyzer 6.03 Installation and Running on Microsoft Windows 8

    Demonstration of DB Query Analyzer 6.03 Installation and Running on Microsoft Windows 8 Ma Genfeng ( ...

随机推荐

  1. PyCharm中Django项目主urls导入应用中views的红线问题

    PyCharm中Django项目主urls导入应用中views的红线问题 使用PyCharm学习Django框架,从项目的主urls中导入app中的views的时候,导入的包中下面有红线报错,但是却能 ...

  2. codeforces 792A-D

    先刷前四题,剩下的有空补. 792A New Bus Route 题意:给出x 轴上的n 个点,问两个点之间的最短距离是多少,有多少个最短距离. 思路:排序后遍历. 代码: #include<s ...

  3. java循环1

    public class f_w { public static void main(String []args) { int a=0; System.out.print("_info__w ...

  4. react 入坑笔记(六) - 组件的生命周期

    React 组件生命周期 详细参考: react 组件生命周期 组件的生命周期可分为三个状态: 1.Mounting:已经挂载/插入到真实 DOM 树上: 2.Updating:正在被重新渲染: 3. ...

  5. python3中的 zip()函数 和python2中的 zip()函数 的区别

    python3中的 zip()函数 和python2中的 zip()函数 的区别: 描述: zip() 函数用于将可迭代对象作为参数,将对象中对应的元素打包成一个个元组,然后返回由这些元组组成的对象. ...

  6. maven:私服的相关配置

    添加到settings.xml中 <server> <id>releases</id> <username>admin</username> ...

  7. Ubuntu命令整理

    linux下find命令的使用和总结 - CS408 - 博客园 ubuntu 命令简写和全称 su:Swith user  切换用户,切换到root用户 cat: Concatenate  串联 u ...

  8. Centos 7 搭建 你懂的

    2018-11-21    19:10:18 本文初衷只是为自己下次搭建做个记录,文中代码也是借鉴其他博客的 以下为博客链接 https://www.cnblogs.com/shipengfei/p/ ...

  9. 使用ubuntu做为dotnet core开发环境

    一.安装google浏览器 1.下载安装包(传送门:http://www.google.cn/intl/zh-CN/chrome/browser/desktop/index.html) 2.使用sud ...

  10. Linux-I/O重定向和管道

    Linux I/O重定向 标准输入(stdin):文件描述符0 标准输入(stdout):文件描述符1 标准错误(stderr):文件描述符2 file descriptors(FD,文件描述符 或 ...