欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

中国电信IT研发中心 2019校园招聘笔试F卷 编程题-2018.09.10

发布时间:2024/3/26 编程问答 46 豆豆
生活随笔 收集整理的这篇文章主要介绍了 中国电信IT研发中心 2019校园招聘笔试F卷 编程题-2018.09.10 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

#include <bits/stdc++.h> using namespace std; int arr[26]; int main() {string str;cin >> str;vector<int> vec;for(int i=0; i<str.size(); i++){int temp = str[i]-'a';arr[temp]++;}int minNum = 0;//找出最少的字符 一定要排除字符数量为0的情况for(int i=0; i<26; i++){if(arr[i] != 0){minNum = i;break;}}for(int i=0; i<26; i++){if(arr[i] < arr[minNum] && arr[i] != 0)minNum = i;}//将数量最少的字符对应的数字全部加入vecfor(int i=0; i<26; i++){if(arr[i] == arr[minNum])vec.push_back(i);}for(int i=0; i<str.size(); i++){bool flag = true;int temp = str[i]-'a';for(int j=0; j<vec.size(); j++){//判断字符是否主要删除if(vec[j] == temp){flag = false;break;}}if(flag)cout << str[i];}return 0; }


剑指offer原题 牛客网题解 点击链接

#include <iostream> #include <vector> #define min(a, b) (a<b ? a : b); using namespace std; int getUglyNumber(int index) {if(index < 7)return index;vector<int> res(index);res[0] = 1;int t2 = 0, t3 = 0, t5 = 0, i;for(i = 1; i < index; ++i){int minTemp = min(res[t2]*2, res[t3]*3);res[i] = min(res[t5]*5, minTemp);if(res[i] == res[t2]*2)t2++;if(res[i] == res[t3]*3)t3++;if(res[i] == res[t5]*5)t5++;}return res[index - 1]; }int main() {int n;cin >> n;cout << getUglyNumber(n) << endl;return 0; }

KMP扩展
参考链接1
参考链接2

总结

以上是生活随笔为你收集整理的中国电信IT研发中心 2019校园招聘笔试F卷 编程题-2018.09.10的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。