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

字符串字符匹配

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

import java.util.Scanner;

/**
 * @author hll[yellowdradra@foxmail.com]
 * @since 2023-03-24 16:39
 **/
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String shortStr = in.nextLine();
        String longStr = in.nextLine();
        int bitSet = 0;
        for (char c : longStr.toCharArray()) {
            bitSet |= (1 << (c - 'a'));
        }
        for (char c : shortStr.toCharArray()) {
            if ((bitSet & (1 << (c - 'a'))) == 0) {
                System.out.println(false);
                return;
            }
        }
        System.out.println(true);
    }
}

全部评论

相关推荐

北漂的牛马人:211佬,包进的,可能是系统问题
点赞 评论 收藏
分享
asdasdasdasdas:19岁,不容易啊可能升个本会好点,现在学历歧视太严重了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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