题解 | #字符串字符匹配#

字符串字符匹配

http://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93

import java.util.; import java.io.; public class Main{ public static void main(String[] args)throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String str = null; while((str = in.readLine()) != null){ Set set = new HashSet<>(); String temp = in.readLine(); for(int i = 0;i < temp.length();i++){ if(!set.contains(temp.charAt(i))){ set.add(temp.charAt(i)); } } int flag = 0; for(int i = 0;i < str.length();i++){ if(!set.contains(str.charAt(i))){ flag = 1; break; } } if(flag == 0){ System.out.println(true); }else{ System.out.println(false); } } } }

我居南半坡 文章被收录于专栏

多刷题,积蓄力量,欢迎讨论

全部评论

相关推荐

点赞 评论 收藏
分享
09-21 23:16
门头沟学院 Java
传奇逃兵王:招不起就别招,叽里咕噜说啥呢
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务