当前位置:网站首页>LeetCode522-最长特殊序列II-哈希表-字符串-双指针
LeetCode522-最长特殊序列II-哈希表-字符串-双指针
2022-07-01 04:48:00 【李烦烦搞快点】
Note:
遍历列表,每次去判断当前的字符串是否不是其他字符串的子串,如果是,那就记录一下最长的答案,如果不是,那么就看其他的
代码如下:
class Solution {
public:
bool check(string s1, string s2){
int k = 0;
for(auto a: s2){
if(s1[k] == a)
k ++;
}
return k == s1.size();
}
int findLUSlength(vector<string>& strs) {
int res = -1;
for(int i = 0; i < strs.size(); i ++){
bool is_sub = false;
for(int j = 0; j < strs.size(); j ++){
if(i != j && check(strs[i], strs[j])){
is_sub = true;
break;
}
}
if(!is_sub)
res = max(res, (int)strs[i].size());
}
return res;
}
};
边栏推荐
- Use and modification of prior network model
- Openresty rewrites the location of 302
- 分布式锁的实现
- Shell之分析服务器日志命令集锦
- RDF query language SPARQL
- Sorting out 49 reports of knowledge map industry conference | AI sees the future with wisdom
- Research on medical knowledge atlas question answering system (I)
- LeetCode_35(搜索插入位置)
- Neural network - nonlinear activation
- js解决浮点数相乘精度丢失问题
猜你喜欢

【硬十宝典】——1.【基础知识】电源的分类
![[hard ten treasures] - 2 [basic knowledge] characteristics of various topological structures of switching power supply](/img/c2/6dfb9f477306edb46ff2a6a6ca32dd.png)
[hard ten treasures] - 2 [basic knowledge] characteristics of various topological structures of switching power supply

LM small programmable controller software (based on CoDeSys) note 20: PLC controls stepping motor through driver
![AssertionError assert I.ndim == 4 and I.shape[1] == 3](/img/b1/0109bb0f893eb4c8915df36c100907.png)
AssertionError assert I.ndim == 4 and I.shape[1] == 3

Dataloader的使用

PR 2021 quick start tutorial, learn about the and functions of the timeline panel

无器械健身

CF1638E. Colorful operations Kodori tree + differential tree array

分布式事务-解决方案
![[pat (basic level) practice] - [simple simulation] 1064 friends](/img/37/0ef0f8aae15ae574be1d76c97497c9.jpg)
[pat (basic level) practice] - [simple simulation] 1064 friends
随机推荐
[hardware ten treasures catalogue] - reprinted from "hardware 100000 whys" (under continuous update ~ ~)
Matters behind the construction of paint testing laboratory
【暑期每日一题】洛谷 P1568 赛跑
Basic skeleton of neural network nn Use of moudle
Pytorch convolution operation
Cmake selecting compilers and setting compiler options
【硬十宝典】——2.【基础知识】开关电源各种拓扑结构的特点
pytorch 卷积操作
Sorting out 49 reports of knowledge map industry conference | AI sees the future with wisdom
Pytest automated testing - compare robotframework framework
I also gave you the MySQL interview questions of Boda factory. If you need to come in and take your own
Pytoch (II) -- activation function, loss function and its gradient
pytorch神经网络搭建 模板
神经网络-使用Sequential搭建神经网络
【暑期每日一题】洛谷 P2026 求一次函数解析式
2022 hoisting machinery command registration examination and hoisting machinery command examination registration
RuntimeError: “max_pool2d“ not implemented for ‘Long‘
Registration of P cylinder filling examination in 2022 and analysis of P cylinder filling
LeetCode_53(最大子数组和)
LeetCode_ 53 (maximum subarray and)
