Fork me on GitHub

牛客网编程练习之编程马拉松:强势糖果

image

image

 

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;
	}

}

 

题目来源: https://www.nowcoder.com/practice/f2c850d6937f4dbb8579de37cd7e44a9?tpId=3&tqId=10897&tPage=1&rp=&ru=/ta/hackathon&qru=/ta/hackathon/question-ranking

posted @ 2017-12-11 02:21  CC11001100  阅读(527)  评论(0编辑  收藏  举报