牛客网编程练习之编程马拉松:强势糖果
AC代码:
import java.util.Scanner; /** * @author CC11001100 */ public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNextLine()){ String[] ss = sc.nextLine().split("\\s+"); System.out.println(resolve(ss[0], ss[1]) ? "Yes" : "No"); } } private static boolean resolve(String s1, String s2){ if(s2.length()>=s1.length()) return false; int[] b1 = new int[26]; int[] b2 = new int[26]; for(int i=0; i<s1.length(); i++){ b1[s1.charAt(i)-'A'] = 1; } for(int i=0; i<s2.length(); i++){ b2[s2.charAt(i)-'A'] = 1; } for(int i=0; i<26;i ++){ if(b2[i]==1 && b1[i]==0) return false; } return true; } }