当前位置:网站首页>Leetcode522- longest special sequence ii- hash table - String - double pointer
Leetcode522- longest special sequence ii- hash table - String - double pointer
2022-07-01 04:53:00 【Li Fan, hurry up】
Note:
Traverse the list , Each time, judge whether the current string is not a substring of other strings , If it is , Record the longest answer , If not , Then it depends on others
The code is as follows :
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;
}
};
边栏推荐
- Leecode record 1351 negative numbers in statistical ordered matrix
- Neural network convolution layer
- 技术分享| 融合调度中的广播功能设计
- This sideline workload is small, 10-15k, free unlimited massage
- RuntimeError: “max_pool2d“ not implemented for ‘Long‘
- 分布式数据库数据一致性的原理、与技术实现方案
- Pytorch(二) —— 激活函数、损失函数及其梯度
- C#读写应用程序配置文件App.exe.config,并在界面上显示
- STM32 expansion board digital tube display
- Basic exercise of test questions hexadecimal to decimal
猜你喜欢

Openresty rewrites the location of 302

Implementation of distributed lock
![解决:Thread 1:[<*>setValue:forUndefinedKey]:this class is not key value coding-compliant for the key *](/img/88/0b99d1db2cdc70ab72d2b3c623dfaa.jpg)
解决:Thread 1:[<*>setValue:forUndefinedKey]:this class is not key value coding-compliant for the key *

Difficulties in the development of knowledge map & the importance of building industry knowledge map
![Solution: thread 1:[< *> setvalue:forundefined key]: this class is not key value coding compliant for the key*](/img/88/0b99d1db2cdc70ab72d2b3c623dfaa.jpg)
Solution: thread 1:[< *> setvalue:forundefined key]: this class is not key value coding compliant for the key*

神经网络-使用Sequential搭建神经网络

Neural network - nonlinear activation

Distributed - summary list

Distributed transactions - Solutions

LeetCode1497-检查数组对是否可以被 k 整除-数组-哈希表-计数
随机推荐
PR 2021 quick start tutorial, learn about the and functions of the timeline panel
Leecode records the number of good segmentation of 1525 strings
【暑期每日一题】洛谷 P2026 求一次函数解析式
【硬十宝典】——2.【基础知识】开关电源各种拓扑结构的特点
Distributed - summary list
[une question par jour pendant l'été] course luogu p1568
Use of dataloader
[daily question in summer] Luogu p2026 find the analytic formula of primary function
js解决浮点数相乘精度丢失问题
技术分享| 融合调度中的广播功能设计
Pytorch(二) —— 激活函数、损失函数及其梯度
Detailed explanation of distributed global unique ID solution
[daily question in summer] first time, second time, deal!
[hardware ten treasures catalogue] - reprinted from "hardware 100000 whys" (under continuous update ~ ~)
Common UNIX Operation and maintenance commands of shell
分布式数据库数据一致性的原理、与技术实现方案
Quelques outils dont les chiens scientifiques pourraient avoir besoin
Basic usage, principle and details of session
RuntimeError: “max_pool2d“ not implemented for ‘Long‘
[summer daily question] Luogu p5886 Hello, 2020!
