Summary: Do not know the written test to the camera, the base of the desktop computer began to wait for the written test. Test only know to camera, immediately ran back to the dorm to take a notebook, back to base, waste more than half an hour more, people are exhausted. Start the computer to do the problem, debugging has failed, time-out, running a virtual machine error, and other problems, is 101 test site problems, Ah, the first time to the pit miserable.
Intern National written test, a total of 3+4 questions:
(1) gives two int, returns the number of different bits in the corresponding position of the second binary form. That is, a maximum of 32 bits are different. The answer is between 0~32.
My idea: First of all two number of different or results, statistics of the results in a few 1.
(2) An array of type int with n elements, each representing the stock price for that day. You have two chances to buy and sell, only 1 shares at a time, and before you buy a share, you are guaranteed to have no stock, the question is, what is the maximum benefit of the stock movement?
My idea: It's impossible to buy and sell on the same day, but you can sell and buy on the same day. For example, only provide 3 days of movement, then you can buy the first day, the second day to sell, the next day to buy, the third day to sell, a total of two transactions, the proceeds are two buy and sell price respectively minus the purchase price after the sum. In fact, it is found in an array of 4 numbers, the rule is a<b<=c<d, so (b-a) + (D-C) and the largest, is certainly greater than 0, or not as good as not buy! So the worst case is not to buy. The poor lift is O (n^4). I'm sure you don't want to be poor. Sweep the array first, and record the lowest stock price in the first position, O (n^2). Sweep again, the poor lift B and D, record the maximum sum result returned. Complexity O (n^2).
1 for(i = n1To1 )2 {3 for(j = i1To0 )4 {5Sta[j][i]= from J to Ithe smallest element of 1. 6 }7 }8 9 for(i =1to n1 )Ten { One for(j = i+1to n1 ) A { - ifSum>Max Then -max=sum; the } -}Pseudo Code
(3) to a tree by the way of a pro-connect matrix, ask what the smallest dividing point between two nodes is. I don't know test instructions at all. Test instructions is talking about the git version of a tree given what, examples are only 1, can not understand what meaning. There will be no more.
(6) Server add-on: The design and calculation of small problems, the remaining 20s to see this problem. Forgot.
On Xiaomi written test