当前位置:网站首页>2022.6.27-----leetcode. five hundred and twenty-two
2022.6.27-----leetcode. five hundred and twenty-two
2022-06-29 07:15:00 【Lu 727】
public int findLUSlength(String[] strs) {
int n = strs.length;
int ans = -1;
// Enumerate strings
for (int i = 0; i < n; ++i) {
boolean check = true;
// Determine whether other strings contain the character sequence
for (int j = 0; j < n; ++j) {
// Determine whether the former is a subsequence of the latter
if (i != j && isSubseq(strs[i], strs[j])) {
check = false;
break;
}
}
// If not, it can be a special sequence
if (check) {
ans = Math.max(ans, strs[i].length());
}
}
return ans;
}
public boolean isSubseq(String s, String t) {
int ptS = 0, ptT = 0;
while (ptS < s.length() && ptT < t.length()) {
if (s.charAt(ptS) == t.charAt(ptT)) {
++ptS;
}
++ptT;
}
return ptS == s.length();
}边栏推荐
- The meaning and calculation method of receptive field
- 多模态 —— Learnable pooling with Context Gating for video classification
- QT foreach keyword
- Method of changing host name (permanent)
- JDBC connects to the database and socket sends the client.
- Introduction to Ceres Quartet
- YGG cooperated with Web3 platform leader to empower the creative community with Dao tools and resources
- QT serial port programming
- Introduction to QT qfileinfo
- NoSQL数据库之Redis(一):安装 & 简介
猜你喜欢
随机推荐
JVM系列之对象深度探秘
Exploring the depth of objects in JVM series
Exclusive download. Alibaba cloud native brings 10+ technical experts to bring new possibilities of cloud native and cloud future
Differences between JSON objects and JSON strings
To: Hou Hong: the key to enterprise digital transformation is not technology, but strategy
Ci tool Jenkins II: build a simple CI project
Database - Synonyms
. NETCORE uses redis to limit the number of interface accesses
Idea integrated code cloud
LiveData源码赏析 —— 基本使用
存token获取token刷新token发送header头
NoSQL数据库之Redis(五):Redis_Jedis_测试
Qt STL类型迭代器
Summary of some new datasets proposed by cvpr2021
Shift/space studio "Aurora" project: building a villa in the sandbox metauniverse
电子商务盛行,怎么提高商店转换率?
Introduction to Ceres Quartet
And check the collection hello
消息队列之通过幂等设计和原子锁避免重复退款
Analytic hierarchy process








