Experience sharing of byte beat back-end interview in April 2020

file
ByteDance's back-end interview experience in April 2020

First side

  • Interview remotely using Niuke.com
  • The interviewer first introduced that there will be several rounds of interviews
Algorithm Question 1.1

Convert integer to binary
and then negative

Algorithm Problem 1.2 The Maximum Profit of Trading Stocks

Given an array representing the daily price of the stock, what is the maximum profit when buying and selling multiple times?
If the dates do not overlap, you can buy and sell multiple times?
Enter: {100, 80, 120, 130, 70, 60, 100, 125}
You can buy and sell multiple times: 115 (80 buy, 130 sell; 60 buy 125 Sell)
Tip: There is no need to output the sequence of buying and selling, only need to get the maximum profit

  • What is the time complexity
  • What is the space complexity
True or False
2.1 What is wrong with this code, if solved
total := 0
for i := 1; i <= 10; i++ {
	sum += i
	go func() {
		total += i
	}()
}
fmt.Printf("total:%d sum %d", total, sum)

This code is executed in the coroutine, which will cause data inconsistency.
You can use locking to avoid

  • How to lock? Code to achieve

code show as below:

var lo sync.Mutex
func main() {
	total := 0
	for i := 1; i <= 10; i++ {
		nums += i
		lo.Lock()
		go func() {
			total += i
			lo.Unlock()
		}()
	}
	fmt.Printf("total:%d", total)
}
  • Do you have any other questions
3 Other assessments
3.1 HTTP status code

400 500 status code

HTTP message format

Not sure ...
Solution:

3.2 HTTP request method

GET Get POST Create PUT Modify DELETE Delete

  • What is the difference between get post

Personally, I said that get is relatively safe without post. All parameters are placed on the URL. Post will wrap the parameters into a request body.

  • What is the difference between capturing post and get

url will be included with some parameters GET request, Ethereal can see, are transmitted in the clear, and the POST in the url will not see
a better answer: https://www.zhihu.com/question/28586791

4 Database
4.1 mysql transaction

Transactions are mainly used to process data with large operations and high complexity. For example, in the personnel management system, you delete a person, you need to delete the basic information of the person, but also delete the information related to the person, such as mailbox, article, etc., so that these database operation statements constitute a transaction
Scheduled tasks

  • What are the isolation levels

~

4.2 How is the MySQL database index implemented?

The B + tree is used
because the B + tree and the jump table are a bit similar, you can directly find the next level

  • Why not use other data structures?

Because if the amount of data is particularly large, the large amount of data search will affect performance, and the B + tree just solves this problem.

4.3 How to add the fastest index for this database
select * from table_name where c> 10 and a = 10 and b = 10;

First of all, we should optimize the value of only query, we can change * to the key
that needs to be queried because c is dynamic, we can add a joint index according to a and b to achieve the best speed

5 Project related
What framework did you use for the crawler in the project
  • What is the use of framework
  • How to do high concurrency, is there a microservice
  • If you want to do distributed, how to achieve

Implemented with kafka, grab data and use kafka for consumption

  • What information is deposited

Save to list

  • Did you not do the search function

No, if this requirement can be stored to ES, use es to find

6 What else do you have to ask

About when there will be results

  • Reply within five working days

Guess you like

Origin www.cnblogs.com/luolianxi/p/12728357.html