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

字符串字符匹配

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

import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        while(in.hasNextLine()){
            String s1 = in.nextLine();
            String s2 = in.nextLine();
            HashSet<Character> hs = new HashSet<Character>();
            for(char c: s2.toCharArray() ){
                hs.add(c);
            }
            int flag =1;
            for(int i =0; i<s1.length(); i++){
                if( !hs.contains(s1.charAt(i)) ){ 
                    //如果没有包含
                    flag =0;//false
                }
            }//for_i
            if(flag == 1){System.out.println("true");}
            else{System.out.println("false");}
        }//while
    }//main
}//Main
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务