1684. 统计一致字符串的数目

1684. 统计一致字符串的数目

class Solution {
    public int countConsistentStrings(String allowed, String[] words) {
        int[] flag = new int[30];
        char[] all = allowed.toCharArray();
        for(int i = 0; i < all.length; i ++) {
            int index = all[i] - 'a';
            flag[index] = 1;
        }
        int res = 0;
        for(String word : words) {
            boolean f = true;
            for(int i = 0; i < word.length(); i ++) {
                int index = word.charAt(i)  - 'a';
                if(flag[index] != 1) {
                    f = false;
                    break;
                }
            }
            if(f) res ++;
        }
        return res;

    }
}
posted @   Eiffelzero  阅读(12)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
点击右上角即可分享
微信分享提示