字节一面凉经-CrossPlatform
没问八股,问了些项目相关的
+ 如何提高项目并发性可用性
+ 如何支持多个用户的群聊需求
+ 根据项目和专业:国密和国外的算法区别是什么
+ 项目会被中间人攻击吗,如何防止或者实施
+ 平常会怎么使用AI Coding
+ CPP如何管理内存,如何排查和处理内存泄露
手撕
说白了就是求一个有向无环图的拓扑排序,但是鼠鼠代码能力为零直接拉了坨大的来了个 $O(n^2)$ 解。
```cpp
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int list[256];
map<string, vector<string>> components = {
{"A", {"B", "C"}},
{"D", {"B", "C"}},
{"E", {"F", "B"}},
{"B", {"L", "F"}},
{"L", {}},
{"N", {}},
{"F", {}},
{"C", {"B"}},
{"P", {"N"}},
{"Q", {"P"}}
};
vector<string> solution(map<string, vector<string>> components) {
vector<string> res;
while(1) {
for(auto &item: components) {
auto index = int(item.first[0]);
if(list[index] != -1) continue;
for(int i = 0; i < item.second.size(); i++) {
auto index_ = item.second[i][0];
if(list[int(index_)]==-1) goto end;
}
list[index] = 1;
res.push_back(item.first);
if (res.size()==components.size()) {
return res;
}
end:
}
}
}
int main() {
for(int i = 0; i < 256; i++) {
list[i] = -1;
}
auto res = solution(components);
for(auto i : res) {
cout << i << " ";
}
}
```
#字节# #暑期实习# #暑期#
+ 如何提高项目并发性可用性
+ 如何支持多个用户的群聊需求
+ 根据项目和专业:国密和国外的算法区别是什么
+ 项目会被中间人攻击吗,如何防止或者实施
+ 平常会怎么使用AI Coding
+ CPP如何管理内存,如何排查和处理内存泄露
手撕
说白了就是求一个有向无环图的拓扑排序,但是鼠鼠代码能力为零直接拉了坨大的来了个 $O(n^2)$ 解。
```cpp
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int list[256];
map<string, vector<string>> components = {
{"A", {"B", "C"}},
{"D", {"B", "C"}},
{"E", {"F", "B"}},
{"B", {"L", "F"}},
{"L", {}},
{"N", {}},
{"F", {}},
{"C", {"B"}},
{"P", {"N"}},
{"Q", {"P"}}
};
vector<string> solution(map<string, vector<string>> components) {
vector<string> res;
while(1) {
for(auto &item: components) {
auto index = int(item.first[0]);
if(list[index] != -1) continue;
for(int i = 0; i < item.second.size(); i++) {
auto index_ = item.second[i][0];
if(list[int(index_)]==-1) goto end;
}
list[index] = 1;
res.push_back(item.first);
if (res.size()==components.size()) {
return res;
}
end:
}
}
}
int main() {
for(int i = 0; i < 256; i++) {
list[i] = -1;
}
auto res = solution(components);
for(auto i : res) {
cout << i << " ";
}
}
```
#字节# #暑期实习# #暑期#
全部评论
相关推荐
查看8道真题和解析 点赞 评论 收藏
分享
