Xiaohongshu C++ side (technical side, 50min)

Xiaohongshu C++ side (technical side, 50min)

interviewer asks

  • Self introduction

  • The projects on your resume are quite diverse, why did you do these projects?

  • what do you think you want to do in the future

  • Pick a project that you think is the most difficult, and then introduce it, balabala

  • project question balabala

  • Could you tell me about some of the difficulties encountered in the project?

  • What is your main reason for writing this project

  • You mentioned it just now CDN, so CDNwhy can it be accelerated, and what is the principle?

  • C++What are the steps in the compilation from source code to executable file?

  • Do you know the difference between G++ o(1), O(2), and these optimizations when compiling ?O(3)

  • Is there any way to manipulate the heap space of the operating system?

  • mallocWhat is the difference between , freeand new?delete

  • mallocWhat happens to the operating system when

  • mallocHow did you do it? Let me briefly explain the principle.

  • Can you tell me the difference between process and thread?

  • What will happen during the process switching process? For example, a core can only run one process at a time, so what will happen when the process is switched?

  • What are the methods of inter-process communication?

  • How does shared memory work? Can you tell me about its principle?

  • In addition to mutexachieving inter-process synchronization, what else can achieve inter-process synchronization?

  • What are the additions to the C++11 standard?

  • Throw me a programming question:

insert image description here

Idea: We don't need to care about which rows and columns are dyed, we only need to care about the number of rows and columns dyed, and then it is the product of the two combination numbers

#include <bits/stdc++.h>
using namespace std;

#define ll long long

ll C(int n,int m) {
    
    
	int ans = 1;
	
	for(int i = 1;i <= m; ++i) {
    
    
		ans *= (n-i+1);
		ans /= i;
	}
	
	return ans;
}


int main()
{
    
    
	ll n,k;
	cin>>n>>k;
	ll ans = 0;
	for(int i = 0;i <= n; ++i) {
    
    
		for(int j = 0;j <= n; ++j) {
    
    
			ll cnt = i * n + j * n - i * j;
			if(cnt == k) {
    
    
				ll line = C(n,i);
				ll row = C(n,j);
				ans += line * row;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

ask the interviewer

  • I would like to ask what is the job of the smart distribution job I applied for, is it biased towards algorithms or applications?
    Answer: (simple answer) I have been involved in both aspects

Guess you like

Origin blog.csdn.net/m0_46201544/article/details/127453220