When diving in the group to see the speeches of big men, was attracted by the interview experience of a big man. This big guy interviewed ali local life summer development internship, the first two have passed, but cool in three. Feel sorry for him at the same time, also want to sort out his experience, hope to let friends pay more attention to.

The thing is, one side, at that time, there was no written test, suddenly received a phone call, and the interviewer said that there is no written test, how to one side, are not ready, the interviewer came to a sentence, do not let you prepare, now start. The second interview is a video interview at a movie theater. There was no news for a long time after the end of the second interview. After a period of time, the third interview began. The project part was not well answered, and the system had ended.

Now let’s take a look at this big shot’s interview questions

One side

1. Why do databases use B+ trees as indexes instead of hash tables

2. How to determine whether a linked list has a ring structure

3. Performance analysis of arrays and linked lists

The problem: A frog can jump up one step or two at a time. Find out how many ways the frog can jump up n steps.

At the beginning of the fourth question, I answered the one-dimensional dynamic programming, but unexpectedly the interviewer wanted him to answer the Fibonacci sequence general term.

One side is really that short, the answer to the first question is not very good.

Post some code for question 4 (FYI only)

public class Fibonacci {
  public int fibonacci(int n) {
    int[] dp = { 1.1.0 };
    if (n < 2) {
      return 1;
    }
    for (int i = 2; i <= n; i++) {
      // F (n) = f(n-1) + f(n-2)
      dp[2] = dp[0] + dp[1];
      dp[0] = dp[1];
      dp[1] = dp[2];
    }
    return dp[2];
  }

  public static void main(String[] args) {
    Fibonacci fb = new Fibonacci();
    for (int i = 0; i < 10; i++) {
      System.out.print(fb.fibonacci(i));
      System.out.print(""); }}}Copy the code
class Solution {
     public int numWays(int n) {
 // This topic is actually a variant of Fibonacci sequence, using the array method
         if(n == 0 || n == 1)
             return 1;
         else {
             int[] arr = new int[n + 1];
             arr[0] = 1;
             arr[1] = 1;
             for (int i = 2; i < n + 1; i++) {
                 arr[i] = (arr[i - 1] + arr[i - 2]) %1000000007;
            }
             returnarr[n]; }}}Copy the code

After one side, the written test, the written test is too bad, so try a question (Bo Le system)

Add test: give you a length of N linked list. N is big, but you don’t know how big N is, and your task is to randomly pick K of these N elements. You can only go through the list once, and your algorithm must ensure that there are exactly K elements that are completely random (with equal probability).

Here’s how he did it:

import java.util.*;
public class Solution{
   public int[] Main(ListNode root,int k)
   {
     
     // Accept the first k
     int[] samples[]=new int[k];
     Node temp=root;
     for(int i=0; i<k; i++) { samples[i]=temp.val; temp=temp.next; }// Record the subscript value of the element
     int p=k;
     // Generate a random number
     Random random=new Random();
     int j;
     // Start processing
     while(temp! =null)
     {
       
       j=random.nextInt(p+1);
       If the number is less than k, accept it
       if(j<k)
       {
         samples[j]=temp.val;
       }
       temp=temp.next;
       // The index is ++
       p++;
     }
     returnsamples; }}}Copy the code

Second interview

1, the role of database index and advantages and disadvantages

2. Can the JAVA keyword satics and private be overwritten

3. Difference between method overrides and overloading

4. Distinction between abstract classes and interfaces

The importance of hascode and equals methods

6. Methods to start threads

Index the data structure of the B+ tree

ConcurrentHasMap JDK1.7 and JDK1.8 have lock granularity

On three sides

1. Why should the fast pointer be set to 1 in the process of judging that the linked list has rings? Can it be set to other values? Must we meet?

2. Determine whether a number is prime. Why is the upper limit of the traversal process square root

3. The Posting process in the project

4. How to realize circular reference reply to posts in the project

5, the implementation process of hot post

6, how to centrally delete a part of the popular post (such as a location)

7, how to realize the expression in the post

summary

It is a pity that the first and second interviews are conducted out of the blue and unprepared. The written test was also unsatisfactory. Three sides when the project part is also deducted points. The whole process down, unsatisfactory place many. I also hope that friends can pay more attention to meet every interview in a perfect state.

Interviews come out of the park and test not only your knowledge base but also your ability to respond on the spot. I sorted out a number of Internet companies for many years of interview questions, a number of big-shot data, as well as Java learning materials, to help you in the interview, calm response. Need friends can click into, code: nuggets

How do you feel after reading the interview materials summarized in this article? Whether the interview questions summarized above can be easily dealt with.

If this article helps you. Don’t forget to like and retweet. Thank you for watching.