关注
那个求最长上升序列长度的 写了本地过了 还有那个双生字符串,就是求循环字符的匹配 一直卡在数据的格式输入 package zijie;
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int n;
int t;
ArrayList<ArrayList<String>> all_str = new ArrayList<ArrayList<String>>();
Scanner sc1 = new Scanner(System.in);
Scanner sc2 = new Scanner(System.in);
t = sc1.nextInt();
for(int i = 0; i < t; i++) {
// 这里想打人
n = Integer.valueOf(sc1.nextLine());
ArrayList<String> one_str = new ArrayList<>();
for(int j = 0; j < n + 1; j++) {
String str = sc1.nextLine();
one_str.add(str);
}
// sc1.nextLine();
System.out.println(one_str);
all_str.add(one_str);
}
sc1.close();
for(int i = 0; i < t; i++) {
ArrayList<String> ar_str = new ArrayList<>();
System.out.println(ar_str);
if(judge(ar_str) == true) {
System.out.println("Yeah");
}else {
System.out.println("Sad");
}
}
}
private static boolean judge(ArrayList<String> ar_str) {
int n = ar_str.size();
for(int i = 0; i < n; i++) {
for(int j = i; j < n; j++) {
return to_judge(ar_str.get(i), ar_str.get(j));
}
}
return false;
}
private static boolean to_judge(String string, String string2) {
String add_str = string + string;
System.out.println(add_str );
if(add_str.indexOf(string2) != -1) {
return true;
}
StringBuffer str_re = new StringBuffer(add_str).reverse();
if(str_re.indexOf(string2) == -1) {
return false;
}else {
return true;
}
}
}
/*
*
*
3
2
helloworld
hdlrowolle
2
helloworld
worldhello
2
abcde
acbde
*/
查看原帖
点赞 评论
相关推荐
点赞 评论 收藏
分享
牛客热帖
更多
正在热议
更多
# 牛客新年AI问运 #
8429次浏览 116人参与
# 你喜欢工作还是上学 #
89512次浏览 883人参与
# 牛客AI体验站 #
16664次浏览 291人参与
# 被AI治愈的瞬间 #
90705次浏览 685人参与
# 你找工作的时候用AI吗? #
173379次浏览 888人参与
# 有必要和同事成为好朋友吗? #
1320次浏览 26人参与
# 如何提高实习转正率? #
87128次浏览 510人参与
# 听劝,这个公司值得去吗 #
665594次浏览 1996人参与
# 你觉得什么岗位会被AI替代 #
41227次浏览 276人参与
# 为了秋招你都做了哪些准备? #
32634次浏览 534人参与
# 机械人的薪资开到多少,才适合去? #
165174次浏览 573人参与
# 你最满意的offer薪资是哪家公司? #
71526次浏览 355人参与
# 这个工作能去吗 #
115268次浏览 662人参与
# 多益网络工作体验 #
63332次浏览 306人参与
# 工作中的卑微时刻 #
33577次浏览 199人参与
# 秋招吐槽大会 #
304816次浏览 1524人参与
# 央国企投递记录 #
177083次浏览 1655人参与
# 国央企求职进展汇总 #
442774次浏览 3509人参与
# 数字马力求职进展汇总 #
331788次浏览 2381人参与
# 你已经投递多少份简历了 #
1353110次浏览 10821人参与
网易游戏公司福利 637人发布