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

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

 

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

相关文章:

  • 2021-09-03
  • 2022-12-23
  • 2021-07-25
  • 2021-04-04
  • 2021-05-16
  • 2021-06-26
  • 2021-06-14
  • 2021-06-10
猜你喜欢
  • 2021-07-13
  • 2021-10-10
  • 2022-12-23
  • 2021-11-17
  • 2021-05-16
  • 2021-06-07
  • 2021-09-25
相关资源
相似解决方案