题解 | #字符串字符匹配#
字符串字符匹配
https://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String a, b; try { a = in.readLine(); b = in.readLine(); } catch (IOException e) { throw new RuntimeException(e); } char[] charAyShort = a.toCharArray(); char[] charAyLong = b.toCharArray(); short i = 0, ls = (short) charAyShort.length, ll = (short) charAyLong.length; int[] as = new int[123]; int[] al = new int[123]; boolean contain = true; while (i < ls) { as[charAyShort[i]] = 1; i++; } i = 0; while (i < ll) { al[charAyLong[i]] = 1; i++; } i = 0; while (i < 123) { if (as[i] == 1 && al[i] == 0) { contain = false; break; } i++; } System.out.print(contain); } }