题解 | #字符串字符匹配#
字符串字符匹配
https://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93
import java.util.*; public class Main { public static void main(String[] args) { Scanner fzhinput = new Scanner(System.in); String zfc1 = fzhinput.nextLine(); String zfc2 = fzhinput.nextLine(); boolean pd = true; LinkedHashMap<Character,Integer> js = new LinkedHashMap<>(); for(int i=0;i<zfc2.length();i++){ js.put(zfc2.charAt(i),js.getOrDefault(zfc2.charAt(i),0)+1); } for(int i=0;i<zfc1.length();i++){ char c = zfc1.charAt(i); if(!js.containsKey(c)||js.get(c)==0){ pd = false; break; } } System.out.print(pd); } }