百度前端暑期实习笔试-3.13
选择题
(终于是正经前端题了),虽然考的都是我不太熟的东西
,只能说这题很前端。
编程题(AK)
最后一题稀里糊涂过了,反正就是过了
第一题,计数(忘记c++怎么遍历map了)
#include<bits/stdc++.h> #include<cstring> using namespace std; string str = "Baidu"; int arr[300]; int main() { int t; cin >> t; while(t--) { string s; cin >> s; if(s.length() != 5) { cout<< "No" << endl; continue; } for(int i = 0; i < str.size(); i++) { arr[(int)str[i]] = 1; } for(int i = 0; i < s.size(); i++) { arr[(int)s[i]] --; } int flag = true; for(int i = 0; i < str.size(); i++) { if(arr[(int)str[i]] == 1) flag = false; } if(flag) cout<< "Yes" << endl; else cout<< "No" << endl; } }
第二题,滑动窗口
#include<bits/stdc++.h> #include<cstring> using namespace std; int a[10010]; struct node { int val, cnt; }b[10010]; int main() { int t; cin >> t; while(t--) { int n, k; scanf("%d%d", &n, &k); for(int i = 0 ; i < n; i ++) { scanf("%d", &a[i]); } sort(a, a + n); int cnt = 0; memset(b, 0, sizeof(b)); b[0].val = a[0]; b[0].cnt = 1; for(int i = 1; i < n; i++) { if(a[i] == a[i - 1])b[cnt].cnt ++; else { b[++cnt].cnt = 1; b[cnt].val = a[i]; } } int tot = 0; int l = 0, r = 0; while(r < n) { while(tot < k && r < n) { tot += b[r++].cnt; } while(tot > k && l < r) { tot -= b[l++].cnt; } if(tot == k) break; } if(tot == k) { cout << b[l].val << ' ' << b[r - 1].val << endl; } else cout << "-1" << endl; } }
第三题,暴力?反正过了
#include<bits/stdc++.h> using namespace std; int main() { int x; cin >> x; int w = 2; int cnt = 1; while(cnt <= x) { printf("r"); if(cnt + w > x) break; cnt += w; w ++; } x -= cnt; w = 2; cnt = 1; while(cnt <= x) { printf("e"); if(cnt + w > x) break; cnt += w; w ++; } x -= cnt; w = 2; cnt = 1; while(cnt <= x) { printf("d"); if(cnt + w > x) break; cnt += w; w ++; } x -= cnt; w = 2; cnt = 1; while(cnt <= x) { printf("r"); if(cnt + w > x) break; cnt += w; w ++; } x -= cnt; w = 2; cnt = 1; while(cnt <= x) { printf("e"); if(cnt + w > x) break; cnt += w; w ++; } x -= cnt; w = 2; cnt = 1; while(cnt <= x) { printf("d"); if(cnt + w > x) break; cnt += w; w ++; } }#我的实习求职记录##百度笔试##百度##百度前端#
2023年实习面试记录 文章被收录于专栏
记录一下2023年上半年找实习工作的面试情况。