Yesterday, a net friend private letter to me, said to ali interview, completely hit. If ThreadLocal is used in a large number of ThreadLocal sources on the web, private static will be added. He was stumped because he had never thought about it. Coincidentally, today I found that some net friends made fun of a Tencent interview question, let’s have a look.



Programmer help: Tencent interview questions, 64 horses 8 track, how many rounds to choose the fastest four

A programmer posted for help. Second interview Tencent, one of the algorithm: 64 horses, 8 tracks, choose the fastest four horses. A minimum of runs will pick the four fastest horses. Such help is also an instant attracted the onlookers and discussion of the net friends, we first look at the net friends are how to answer this problem, let’s have a look.



Have netizen said. One of ntu’s algorithm projects, Tencent so no creativity? It’s my second interview again. Can you clock it? If you clock it, it’s eight.

Have netizen answer to. Randomly divided into eight groups of games, this is eight games, each group of the first out to run a race, each time the first to choose, the group of the last out to fill the position, with the rest of the run, so run 4 times ok. Twelve times in all. I don’t know if that’s right

There are also netizens to analyze. 64 points 8 groups against 8 games, eliminated the last four in each group; 8 first to 1, after elimination of the four in the group; One of the remaining 16 horses will be the winner, and there will be the last three horses in the first group, the first three horses in the second group, the first two horses in the third group, and the fourth horse in the first group. A total of 9 horses are undecided, and the first three horses will be randomly selected in 1 race of 8 horses. Top three plus one race we missed in the last race, top three plus the permanent winner is the fastest four horses. Is that the idea?



More netizens joined the discussion. Minimum heap sort, 8 rounds, 64 horses each run once, and based on the time each horse takes, take the four fastest horses. I went to Tencent for an internship 7 years ago.

Eight if you can time it. If there is no time, choose 4 horses with chairs at home and send them to Li general office. The remaining 60 will be killed and only 0 races will be run. 8 groups of horses were sorted in 8 rounds. The last four horses in each group were removed and 8 groups were left

Four horses. The first runner eliminated the next four groups, leaving four groups

Four horses. I’m going to do it twice. Every time there’s a number one there’s a sure top four.

This problem doesn’t even give you the basics. 1, the horse’s play is constant, each run the same distance, must be the same time. 2. Can you use a stopwatch? 3. The track length should not be long enough to run dead horses.

Read the answer. Keep narrowing the search space and eliminating as many numbers as possible. On the other hand, when we were down to nine horses, we always thought there was an easier one.

Programmer help: Tencent interview questions, 64 horses 8 track, how many rounds to choose the fastest four



More netizens participated in the answer. 1, divided into 8 groups, each group run once, determine the top 4, the last 4 in each group eliminated, so that after 8 rounds, there are 32 horses left; 2, each group of the first pull out a leg, after four, and his entire team, at the same time line of the first group, champion came out, and then there were three horses, the second group, remove the last, remaining 3 fart, the third group to remove two remaining 2, 1, the final group left so nine rounds down, 9 horse race three places; Three, eight horses, one more round, pick the top three, those three and the other one again, pick the top three. Eleven rounds, all done.

At least 10 races (with 9 races left, the bottom 3 of group 1, the top 3 of group 2, the top 2 of group 3, if the first place of group 3 is greater than or equal to 3, then the top 4 has been ranked), maximum 11 races



There are also more rational netizens to analyze. 8+4+2+1, each race needs to leave the fastest 4, big data interview memory is not enough, need a variant of external sorting, information theory calculation,8 tracks at a time to provide information A8,8, A64, 60. My team also took an examination of this question. I think when I came in, I thought it was not the Olympic Number. It was very simple, and it had not changed for 5 years. It feels like 8 rounds is enough, one for each horse, time each horse on a millisecond clock, go to the top four.

Step one: Divide into 8 groups, each run one round, according to the results of the group number. Each group should run one round according to their scores. There are nine rounds to choose the fastest horse. [1] [2] the horse (the first runner in the first race and the second runner in the second race) and the fastest horse in the first race are the possible second fast horses. Let them run a round of eight. If [1] [2] the horse finishes third in the race. The first and second horses of the race shall be the second and third horses of 64 horses respectively. And [1] [2] was the fourth fastest horse of all. The top four are from 10 rounds. Because the question asks “least”, other possible outcomes are not considered in round 10.

The genius replied:

Read so many netizens’ replies, in fact, there are many correct netizens. It seems to be a simple question, but it is also very comprehensive. I don’t know if you have a clearer answer to the interview question like Tencent. Welcome to leave a message and discuss it with me.

Recommended reading:

What you don’t know about violent recursive algorithms

eggs

Can you answer the three most recent interview questions this year?

For the best solution of these three interview questions, we have specially recorded a whole interview video. If you need it, you can pay attention to the public number [Java Doudi] reply [666] for free

Three things to watch ❤️

= = = = = = = =

If you find this article helpful, I’d like to invite you to do three small favors for me:

Like, forward, have your “like and comment”, is the motivation of my creation.

Follow the public account “Java Doudi” to share original knowledge from time to time.

Also look forward to the follow-up article ing🚀