当前位置:网站首页>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();
}边栏推荐
- Instanceklass "suggestions collection" of hotspot class model
- IDEA常用插件
- Genicam gentl standard ver1.5 (3) Chapter 4
- List集合实现分页
- IDEA 集成 码云
- json tobean
- Draw multiple ROC curves on a graph
- Chinese garbled code on idea console [valid through personal test]
- Baidu applet automatically submits search
- try anbox (by quqi99)
猜你喜欢

Introduction to Ceres Quartet

Qt QLineEdit详解

json tobean

About DDNS

json tobean

YGG cooperated with Web3 platform leader to empower the creative community with Dao tools and resources

JDBC connects to the database and socket sends the client.

Annual inventory review of Alibaba cloud's observable practices in 2021

微信小程序学习笔记(暑假)

NoSQL数据库之Redis(二):Redis配置文件介绍
随机推荐
RPC和RMI
QT program packaging and publishing windeployqt tool
The annual technology inventory of cloud primitives was released, and it was the right time to ride the wind and waves
Redis in NoSQL database (4): redis publishing and subscription
QT STL type iterator
NoSQL数据库之Redis(四):Redis新数据类型
Introduction to NoSQL database
Instanceklass "suggestions collection" of hotspot class model
Multimodal learning pooling with context gating for video classification
Vite quick start
利用Jsonp跨域请求数据
List集合实现分页
Qt QFrame详解
Class differences of QT processing image data (qpixmap, qimage, qpicture)
. NETCORE uses redis to limit the number of interface accesses
uva10859
Save token get token refresh token send header header
package.json的所有配置项及其用法,你都熟悉么
关联性——相关性分析
uva11825