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;
- BOOL Isseq (int array[],int len) {//algorithm complexity is NLOGN, you should implement map with Unordered_map
- Map<int,int> MP;
- int minval = 55;
- int wcnt = 0;
- for (int i=0;i<len;i++) {
- if (array[i] = =-1) {
- wcnt++;
- Continue
- }
- Mp[array[i]] = 1;
- if (Array[i] < minval) minval = Array[i];
- }
- int cnt = 1;
- for (int i = minval+1;i<=minval+4;i++) {
- if (Mp[i]) cnt++;
- }
- if (cnt==5) return true;
- if (cnt==4 && wcnt==1) return true;
- if (cnt==3 && wcnt==2) return true;
- return false;
- }
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?
- Vector<int> gettwonum (vector<int> & Input) {
- int len = Input.size ();
- int res = 0;
- for (int i=0;i<len;i++) {
- Res ^= input[i];
- }
- int j=0;
- for (int i=0;i<32;i++) {
- if ((res >> i) & 0x1) {
- j = i;
- Break
- }
- }
- int left = 0;
- int right = 0;
- for (int i=0;i<len;i++) {
- if ((input[i]>>j) & 0x1) {
- Left ^= Input[i];
- } else {
- Right ^= Input[i];
- }
- }
- vector<int> result;
- Result.push_back (left);
- Result.push_back (right);
- return result;
- }
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