150 questions in Baidu written test interview over the years

150 questions in Baidu written test interviews over the years
1. Implement a revert function in C language. Its function is to return the input string in reverse order on the original string.

2. Implement the function void * memmove(void *dest, const void *src, size_t n) in C language. The function of the memmove
function is to copy the first n bytes of the memory content pointed to by src to the address pointed to by dest.
Analysis: Since any type of pointer can be assigned to a pointer of void type, this function mainly realizes the copying of various data types.

3. There is a 27 cm thin wooden pole, and there is an ant on each of the five positions of 3 cm, 7 cm, 11 cm, 17 cm, and 23 cm.
The wooden pole is so thin that one ant cannot pass through it at the same time. At the beginning, it is arbitrary whether the ants' heads are facing left or right. They will only walk forward or turn around, but will not retreat.
When any two ants meet, the two ants will turn around and walk in opposite directions at the same time. Suppose ants can travel a distance of one centimeter per second.
Write a program to find the minimum and maximum time for all ants to leave the wooden pole.

4. Given an array of integers, rearrange the array so that the left side of the array is odd and the right side is even.
Requirements: Space complexity O(1), time complexity O(n).

5. There are n interval segments on the one-dimensional coordinate axis, find the two interval segments with the longest overlapping intervals.

6. There are many tasks in the system, and there are dependencies between tasks. For example, B depends on A, then B can execute after A is executed (
  1) Regardless of system parallelism, design a function (Task *Ptask, int Task_num) without considering parallelism degree, the fastest way to complete all tasks.
  (2) Considering the degree of parallelism, how to design

typedef struct{
      int ID;
     int * child;
      int child_nu

Guess you like

Origin blog.csdn.net/weixin_43860634/article/details/130890902