The latest September Byte Beats surface algorithm is really important: algorithm + Spring + Mysql + thread safety + design pattern + Redis, etc.

This article mainly introduces the latest September Byte Beat: Spring+Mysql+Thread Safety+Reflection+Design Pattern+Redis, etc.
Algorithms are really important~~ The questions below QAQ
Insert picture description here
are just part of the frequently asked interview questions that I have compiled. In addition, I have compiled and collected interview knowledge points from more than 20 years of companies, as well as various Java core knowledge points for free to share with you. The following are just some screenshots. If you want information, you can click here to get it! ! ! Secret code CSDN.Insert picture description here

Algorithm question

List the algorithm questions separately (attach the answers)
1. Code compilation process
• Expand the include file in the cpp file.
• Compile each cpp file into a corresponding obj file.
• Link the obj file into an exe file (or other library files)

2. What are the methods, advantages and disadvantages for finding the smallest k number among 100W integers

Quick sort: When partitioning, divide the array into two parts according to the number P, set the number greater than P as a, and the number less than P as b. If a>=k, take the largest number of k from the number of a, if a<k, then take the largest number of ka-1 from the number of b.

3. What are the methods, advantages and disadvantages of finding the same integer in two 10G files

(1) Fast sorting + binary search (2) Bitmap method

Application of bitmap method

1. Give 4 billion unsigned int integers that are not repeated, and then give a number, how to quickly judge whether this number is among the 4 billion numbers. First, store the 4 billion numbers in the bitmap Then, for the given number, judge whether it is in the bitmap.

2. Use the bitmap method to determine whether there is a repeated traversal of the integer array, put it in the bitmap one by one, and check whether it has appeared in the bitmap, if it does not appear, put it in, otherwise it is a repeated element.

3. Find out non-repeating integers among 250 million integers. Note that the memory is not enough to hold the 250 million integer references: using 2-Bitmap (each number is allocated 2 bits, 00 means not existing, 01 means Occurs once, 10 means multiple times, and 11 is meaningless). In fact, two ordinary Bitmaps can be used here, that is, the first Bitmap stores whether the integer appears or not, if it appears again, just set it in the second Bitmap. In this case, a simple 1-Bitmap can be used.

4. There is a file with a size of 1G, each line in it is a word, the word size does not exceed 16 bytes, and the memory limit is 1M. Return the 100 most frequent words.

Scheme 1: In the sequential reading file, for each word x, take it, and then store it in 5000 small files (denoted as) according to the value. So each file is about 200k. If some of the files exceed 1M in size, you can continue to divide down according to a similar method, knowing that the size of the small files obtained by decomposition does not exceed 1M. For each small file, count the words that appear in each file and the corresponding frequency (trie tree/hash_map, etc. can be used), and take out the 100 words with the largest frequency (the smallest heap containing 100 nodes can be used), And save 100 words and the corresponding frequency into the file, so another 5000 files are obtained. The next step is to merge the 5000 files (similar to merge sort).
5. Mass log data, extract the IP that visits Baidu the most on a certain day.

Solution 1: First of all, this day, and the IPs in the logs of accessing Baidu are taken out and written into a large file one by one. Note that the IP is 32 bits, and there is at most one IP. The same mapping method can be used, such as modulo 1000, to map the entire large file to 1000 small files, and then find the IP with the largest frequency in each small article (you can use hash_map for frequency statistics, and then find the most frequent A) and the corresponding frequency. Then, among the 1000 largest IPs, find the IP with the largest frequency, which is what you want.

6. The causes and solutions of the zombie process:

If the child process exits before the parent process, and the parent process does not call wait/waitpid, the child process will become a zombie process. Through the ps command, we can see that the status of the process is Z (meaning zombie).

Generally, in order to prevent zombie processes from being generated, we must wait for them after fork child processes; at the same time, when the child process exits, the kernel will give the parent process a SIGCHLD signal, so we can create a signal processing function that captures the SIGCHLD signal. Call wait (or waitpid) in the function body to clean up the exited child processes to prevent zombie processes.

7. Give you a linked list of length N. N is big, but you don't know how big N is. Your task is to randomly extract k elements from these N elements. You can only traverse this linked list once. Your algorithm must ensure that exactly k elements are taken out, and they are completely random (equal probability of occurrence).

Solution: First select the first k, from the k+1 element to the last element, select the i-th element with the probability of k/i (i=k+1, k+2,...,N), and randomly Replace an originally selected element, so that k elements are obtained by traversing once, which can ensure completely random selection. This algorithm is called reservoir sampling

8. There are 20 arrays, each of which has 500 arrays in descending order. Each number is a 32-bit unit. Find the largest 500 of these 10,000 numbers.

Combine the 20 arrays into one and connect them next to each other, without ensuring order. Randomly select an element in the merged array, and then place all elements smaller than this element on the left side and greater than to the right. After the operation is completed, if the originally selected element is just at the 500th position from the right, then the element starting from it to the right is the desired element. Otherwise, if the number of elements on the right end is greater than 500, use this method recursively for the right end sequence; otherwise, if the number of left end sequences is greater than 10000-500, use this method recursively for the left end sequence. Complexity expected O(n)

9. Stack problem:

How to use an array to implement two stacks: use the two ends of the array as the starting point of the two stacks and expand to the middle. When the sum of the elements in the two stacks does not exceed n, the two stacks will not meet.
10. Binary tree:

Find the nearest common parent node of any two nodes on the binary tree: first count the depths of the two nodes, then go up (deep-shallow) steps for the deeper one, and finally go up at the same time. Hit the nearest common parent node. If you consider all the nodes of the binary tree as N, my algorithm only needs lg(N).

11. Find all paths whose sum is a certain value in the binary tree:

After reaching a node, calculate the sum of the current node and sum. If it is a target, the output path is returned. If it is greater than the target, it will return directly. If it is less, the value of the current node will be pushed onto the stack, the value of sum will be updated, and the traversal will continue. After that, when returning from the current node, pop it from the stack and update the sum

one side

• Introduce yourself
• Ask the project
• How did you solve the oversold problem in the project?
• java polymorphism?
• Java runtime data area? effect?
• What is reflection?
• How to create objects with reflection? benefit?
• What are the components of the http protocol and how to request it?
•The difference between http and https
•the difference between get and post
•database index
•sql statement to create index

Three programming:
• The first coin problem, how to describe the specific forgotten
• The second: linked list, the common point of the two linked lists
• The third array: how to describe the specific forgotten

Hourglass problem

Two sides

• Introduce yourself
• Introduce the project. Have your projects been launched
• How to solve the difficulties in the project?
• Spring?
• What is the MVC pattern?
• Tell me about the SpringMVC process?
• Tell me about mysql?
• Have you ever practiced
? What are the private IPs?
• Three handshake, four waves?

Programming problem: 100 million rows of iP addresses, find all IPs in the penultimate column

There are other basic questions, I can’t think of it

Three sides

•Introduction to yourself
•How many tables do you have in this project•How many
states does this field of this data table have
•Processes and threads?
• Thread safe?
• Programming question is the maximum sum of consecutive sub-arrays
• Write singleton mode?
• When is the singleton pattern available? I am talking about an example in my project
•What is the factory pattern? Is it useful in your project?
•How many commonly used commands in redis?
• Common Linux commands?

hr noodles

• She first introduced the benefits of her company
• Then why did you choose Shanghai?
• Where is the home from?
• Do your parents agree that you are out?

Interview summary

ByteDance's interviewers are very good. The content of the interview is the most comprehensive since I have interviewed so many. The questions are not particularly tricky, and they all fit the work scene.

Projects are very important. Projects are the stepping stone and are the main part of the interview. If I don't have the two items on the resume, it is estimated that the resume will be difficult to pick up, and it will enter the three sides. Many interview questions are asked from the perspective of the project, and the answer can also be combined with the project answer, which is a bonus.

In addition to the technology used in the project, we should also pay attention to the business and architecture of the project, and it is best to integrate them together and explain clearly.

Only by having more interviews can you change your original "I thought" thinking into "it turns out to be this way."

Guess you like

Origin blog.csdn.net/a646705816/article/details/108652934