当前位置:网站首页>科大讯飞笔试题复盘
科大讯飞笔试题复盘
2022-08-09 02:30:00 【草莓摇摇奶昔-】
第一题:给一个字符串,其中有不定数量空格相隔的一些单词,计算包含字符 e 的单词个数;
这个比较简单,不列题解了;
第二题,给定四点,计算对应的凸四边形面积,点为给定的结构体;
没写出来:这个基本考数学公式,不知道就做不出来,没有参考价值,不去复盘这个了;
第三题,给定一个字符串,求解字符串子序列中 iflytek 的个数
这个也没写出来,g了,回溯模板都写不对了!!!
backtracking(str, i + 1); 不是backtracking(startIndex + 1);
暴力回溯:
#include <iostream>
using namespace std;
string target = "iflytek";
string path;
int res = 0;
bool isPath(string& path) {
for (int i = 0; i < path.size(); ++i) {
if (path[i] != target[i]) return false;
}
return true;
}
void backtracking(const string& str, int startIndex) {
if (!isPath(path)) return;
if (path == target) {
res++;
return;
}
for (int i = startIndex; i < str.size(); ++i) {
path.push_back(str[i]);
backtracking(str, i + 1);
path.pop_back();
}
}
int findiflytek(string& str) {
backtracking(str, 0);
return res;
}
int main() {
string str = "iflytekiflytek";
cout << findiflytek(str) << endl;
return 0;
}
动态规划解法:待看!
边栏推荐
- JS 实现千分位分隔符
- Analysis of when AuthenticationSuccessHandler is called after UsernameAuthenticationFilter is authorized successfully
- NPDP改版前最后一次考试!请注意
- [ANT]apache ant 安装说明
- Etcd realize large-scale application service management of actual combat
- MT4/MQL4入门到精通EA课程第二课-常用的功能函数
- 金融行业软件测试面试题(含答案)| 入门指南
- Likou Brush Question Record 1.5-----367. Valid perfect squares
- Flume (四) --------- Flume 企业开发案例
- ZCMU--5115: Buying Keys(C语言)
猜你喜欢
随机推荐
The most fierce "employee" in history, madly complaining about the billionaire boss Xiao Zha: So rich, he always wears the same clothes!
OJ:L2-012 关于堆的判断
数据库设计的总结
Z-Game on grid(牛客多校赛)
Significance Test--Study Notes
Open3D 点云曲率计算
危化企业双预防机制数字化建设工作要求
力扣刷题记录2.1-----27. 移除元素
opencv在图像上长按左键画矩形单击右键清除
What is the difference between a project manager and a product manager?
【电商运营】不知道怎么做网站优化?这里有你需要知道的一切!
LintCode 283. 三数之中的最大值
DataGridView在多线程中出现大红叉
2020.10.13 Development log
JS 截取数组的最后几个元素
yii2的安装之路
时间复杂度和空间复杂度
MT4 / MQL4 entry to the master of EA course lesson two - commonly used functions
【云计算】XaaS最全介绍(按24字母合集):AaaS、BaaS、CaaS、DaaS、EaaS、FaaS、GaaS、HaaS、IDaaS…
USB 触摸在竖屏时校准