当前位置:网站首页>leetcode每日一题8.6(持续更新)
leetcode每日一题8.6(持续更新)
2022-08-08 06:25:00 【Java技术一点通】
leetcode每日一题 2022年8月6日(持续更新)
思路: 暴力枚举
对于字符串数组中的某个字符串words[i],我们判断它是否是其他字符串的子字符串,只需要枚举words[j],其中j != i,如果words[i]是words[j]的子字符串,那么将words[i]加入到结果中去。
代码实现如下:
class Solution {
public:
vector<string> stringMatching(vector<string>& words) {
vector<string> res;
for (int i = 0; i < words.size(); i ++ ) {
for (int j = 0; j < words.size(); j ++ ) {
if (i != j && words[j].find(words[i]) != string::npos) {
res.push_back(words[i]);
break;
}
}
}
return res;
}
};
关注博主不迷路,内容持续更新中。
边栏推荐
猜你喜欢

Food Industry Report: Research Analysis and Development Prospect Forecast of Chili Market

四. Redis 事务、锁机制秒杀

Chemical Materials Industry Report - Adipic Acid Market Status Research Analysis and Development Prospect Forecast

人脸识别数据集总结

rhcsa——第三天

【嵌入式Linux】SQLite数据库

深度神经网络的训练过程,深度神经网络训练方法

Industry Research: Analysis of the Status and Prospects of the Pension Insurance Market in 2022

Lightning Sixteen Whip

虚拟机克隆 快照 迁移 删除
随机推荐
P17 五子棋的实现4 悔棋功能
二. Redis 数据类型
ps神经网络滤镜安装包,ai神经网络滤镜安装包
神经网络预测结果分析,神经网络怎么预测数据
PyTorch向量变换基本操作
Consumer Goods Industry Report: Research Analysis and Development Prospect Forecast of Cosmetic Container Market Status
MongoDB常用命令整理
Refrigerator compressor market status research analysis and development prospect forecast
RNN神经网络适用于什么,RNN神经网络基本原理
CSDN21天学习挑战赛之顺序查找
6.线程的休眠
基于深度学习的关系抽取
CV代码细节总结(一)
hyperledger-fabric documention official documentation
线程和进程定义
firefly rk3399 硬件解码,多通道解码
P02 线程的用途
RHCSA-配置redhat
Windows中安装MongoDB的PHP扩展
线性回归---Fit A Line