Baidu Web Search Division rank Team 4S interview

Source: Internet
Author: User
Tags disk usage

1. What is the difference between Du and DF?

Du statistics file size, need to traverse the entire directory, DF statistics disk usage; du-s/dir du-ab/dir; Df-h/disk1

Normally the two values are close, but if there is a process to open the file, and the file is out of RM or MV, the directory du free space is larger than DF; because DF records the disk usage size, the process does not close the file, the DF default disk is still used, and the Du traverses the directory, The found file has been removed, so this part size is not recorded;

2. Soft link and hard link difference

Hard Link: And the original file point to the same inode, can be viewed with ls-il, generate an identical file, the same status; Inode number increased by 1;

Cons: Cannot cross file system, only Superuser can create hard link to directory

Soft Connect: Create a new file, save the path of the source file within the file, Ls-il can see, the new inode number, and the attribute into L, can cross file system

Disadvantage: If the original file path is changed, the soft connection fails;

3. Draw five cards from poker, the King can replace any card, judging whether it is continuous? Concrete how to use the bucket implementation, you can consider.

Can be implemented with a map, hints to use the bucket sort implementation, at that time do not know what is to understand the sort. Back to see some, the bucket sort is actually the implementation of the hash, the bucket list, implement insert and then merge, the algorithm of the bucket sorting is O (n), the best case for the worst case of sorting is O (Nlogn), and the bucket sort is not based on comparison, so the algorithm complexity is O (n), Implement the process: insert the corresponding linked list, and then merge the buckets in turn;

    1. BOOL Isseq (int array[],int len) {//algorithm complexity is NLOGN, you should implement map with Unordered_map
    2. Map<int,int> MP;
    3. int minval = 55;
    4. int wcnt = 0;
    5. for (int i=0;i<len;i++) {
    6. if (array[i] = =-1) {
    7. wcnt++;
    8. Continue
    9. }
    10. Mp[array[i]] = 1;
    11. if (Array[i] < minval) minval = Array[i];
    12. }
    13. int cnt = 1;
    14. for (int i = minval+1;i<=minval+4;i++) {
    15. if (Mp[i]) cnt++;
    16. }
    17. if (cnt==5) return true;
    18. if (cnt==4 && wcnt==1) return true;
    19. if (cnt==3 && wcnt==2) return true;
    20. return false;
    21. }

Bucket sort deformation: array list, the elements in the array can be ordered, so that only need to sort the list when inserted, and then all the chain tables can be connected;

If the number is sorted, it can be added to the bucket according to the number from left to right, divided into 10 barrels, which indicates 0,1,... 9, the input number is uniform and independent evenly distributed in the bucket range of space, so generally there will not be a lot of chatter in a bucket situation.

4. There are two different numbers in many numbers, how can I find them?

    1. Vector<int> gettwonum (vector<int> & Input) {
    2. int len = Input.size ();
    3. int res = 0;
    4. for (int i=0;i<len;i++) {
    5. Res ^= input[i];
    6. }
    7. int j=0;
    8. for (int i=0;i<32;i++) {
    9. if ((res >> i) & 0x1) {
    10. j = i;
    11. Break
    12. }
    13. }
    14. int left = 0;
    15. int right = 0;
    16. for (int i=0;i<len;i++) {
    17. if ((input[i]>>j) & 0x1) {
    18. Left ^= Input[i];
    19. } else {
    20. Right ^= Input[i];
    21. }
    22. }
    23. vector<int> result;
    24. Result.push_back (left);
    25. Result.push_back (right);
    26. return result;
    27. }

5. Give the word length of the machine

sizeof (size_t) sizeof (int *) uname-a

6. Minimum editing distance? (See http://www.cnblogs.com/purejade/articles/3834883.html)

At that time thinking wrong, using each number to cut, in fact, the editor can add, subtract and replace, but only through the three ways to travel next;

So the recursive relationship should be d[i][j] = min (d[i-1][j]+1,d[i][j-1]+1, (d[i-1][j-1]+ (s1[i-1]==s2[j-1]?0:1)); If replace is 2, change to 2 ; The relationship between the recursive relationship and the first three can be easily obtained;

http://www.programcreek.com/2013/12/edit-distance-in-java/

If S1[i-1]==s2[j-1], then d[i][j] = = D[i-1][j-1]

If s1[i-1]! = s2[j-1], then d[i][j] = min (D[i-1][j] + 1,d[i][j-1] +1,d[i-1][j-1]+1)

7. Logic Questions

Give a number m, go to 1-3 each time, take the last one to lose; say the problem at that time thought for a long time, he gave me a 13, let me want to win strategy, I did not think, the result found this affirmation will lose; The interviewer examines your analytical ideas and gives you a winning strategy. Go ahead no matter how you go, We all give it to 4n+1 number on it, so we must lose first, because go first is equivalent to starting from 5, you will lose;

The method of 8.query semantic analysis

such as Chen Yao-"Chen Yao related pictures tianlong Eight department-" video

1) log, click Extract

2) query clustering and high frequency analysis

3) Special Click, such as Tianlong eight video

Finally, summarize:

This interview, the first topic answer is not very good, recursive relationship is a bit of a problem; but there is a problem, writing jealousy is not standardized, where to write, so that the evaluation of the latter is very unfavorable, later to write at the same time to learn to summarize, the focus is neatly written out.

Baidu Web Search Division rank Team 4S interview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.