Futu SRE Interview

It should be the longest round of interviews I have so far. The whole process is nearly two hours. This article only describes some of the questions. The first one is tearing up two questions by hand. I think there is nothing to say about the first question, so I will record the second question:

  • Insert picture description here
    The pseudo code I gave is as follows. The core idea is to use two TreeMap to track and record the elements and their numbers on both sides, and the time complexity is O(nlogn). Later, I thought about it again, it is possible to use the most value query of the interval , and the time complexity is also O(nlogn)
public class Q4 {
    
    
	List<Integer> getMids(int[] nums){
    
    
		List<Integer> ans = new LinkedList<Integer>();
		if(nums.length<2) {
    
    
			ans = Arrays.stream(nums).boxed().collect(Collectors.toList());
			return ans;
		}
		
		TreeMap<Integer,Integer> ele_no_l = new TreeMap<Integer,Integer>();
		TreeMap<Integer,Integer> ele_no_r = new TreeMap<Integer,Integer>();  
		for(int i=1;i<nums.length;++i) {
    
    
			ele_no_r.put(nums[i], ele_no_r.getOrDefault(nums[i], 0)+1);
		}
		
		for(int i=0;i<nums.length;++i) {
    
    
			if(ele_no_l.lastKey()<nums[i] && ele_no_r.firstKey()>nums[i]) {
    
    
				ans.add(nums[i]);
			}
			ele_no_l.put(nums[i], ele_no_l.getOrDefault(nums[i], 0)+1);
			int newno = ele_no_r.get(nums[i+1])-1;
			if(newno==0) {
    
    
				ele_no_r.remove(nums[i+1]);
			}else
				ele_no_r.put(nums[i+1], newno);
		}
		return ans;
	}
}
  • Do you understand TCP UDP? TCP's TIME-WAIT; does UDP have a connect function? Do you understand IO multiplexing? Select, epoll
    refers to the best epoll explanation I have read : IO multiplexing means that one thread can handle multiple network connections. Use select, polling, there is O(n) time complexity; epoll can be understood as event poll, different from polling, epoll will notify us which stream has occurred and what I/O event, so that the time complexity is reduced To O(1)

  • repeat :

    • How to use redis to implement distributed locks? How to ensure atomicity in this process?
      Reference answer for the latter question: Method 1, Lua script; Method 2, transaction
  • Zombie Process
    Refer to Baidu Encyclopedia and Wikipedia: A zombie process is when the child process ends before the parent process, and the parent process does not reclaim the child process and release the resources occupied by the child process. At this time, the child process will become a zombie process. At this time, its process control block still exists in the process table of the operating system

Guess you like

Origin blog.csdn.net/qq_23204557/article/details/114993735