当前位置:网站首页>科大讯飞笔试题复盘
科大讯飞笔试题复盘
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;
}动态规划解法:待看!
边栏推荐
- yii2的安装之路
- 企业从云服务的承诺支出中获得最大收益的四种方法
- online schema change and create index
- The last exam before the NPDP revision!caution
- Programmer's Daily Life | Daily Fun
- 历史最全DL相关书籍、课程、视频、论文、数据集、会议、框架和工具整理分享
- MT4 / MQL4 entry to the master of EA course lesson two - commonly used functions
- gpio子系统和pinctrl子系统(中)
- <爆>2022中文版-《海外博士申请指南-材料准备、时间线、套磁、面试及录取》免费分享
- 使用JS实现数组扁平化的几种方式
猜你喜欢
随机推荐
炫酷-轮播图-走马灯
The most fierce "employee" in history, madly complaining about the billionaire boss Xiao Zha: So rich, he always wears the same clothes!
Maya engine modeling
My thoughts on software development
数字 06 verilog_关于异步FIFO
Several ways to use JS to achieve array flattening
Likou Brush Question Record 3.1-----977. Square of ordered array
Line segment tree of knowledge
项目经理VS产品经理,二者到底有何不同?
企业面临的五大数据安全挑战
帮助安全红队取得成功的11条建议
Flume (四) --------- Flume 企业开发案例
全志通过fastboot烧写boot.img
2022年最流行的自动化测试工具有哪些?全网最全最细都在这里了
10.1-----19. Delete the Nth node from the bottom of the linked list
How to install yii2
How js implements array deduplication (7 kinds)
如何保护智能家居避免黑客攻击
【Jenkins 学习笔记】玩转持续集成与持续交付
NPDP改版前最后一次考试!请注意







