字符串匹配(java)

字符串匹配

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

import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        while(in.hasNext()){
            String s1 = in.next();
            String s2 = in.next();
            Set<Character> set = new HashSet<>();
            char[] arr1 = s1.toCharArray();
            char[] arr2 = s2.toCharArray();
            for (char c : arr1){
                set.add(c);
            }
            for (char c : arr2){
                if (set.contains(c)) set.remove(c);
            }
            System.out.println(set.size() == 0);
        }
    }
}
全部评论

相关推荐

点赞 2 评论
分享
牛客网
牛客企业服务