题解 | #计算某字符出现次数#
计算某字符出现次数
https://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1
import java.util.*;
import java.util.stream.Collectors;
/**
* @author hll[yellowdradra@foxmail.com]
* @since 2023-03-10 15:21
**/
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String str = in.nextLine();
final Map<String, Integer> map = new HashMap<>(str.length());
Arrays.stream(str.toLowerCase().split("")).map(c -> map.compute(c, (k, v) -> v == null ? 1 : ++v)).collect(Collectors.toList());
System.out.println(map.getOrDefault(in.next().toLowerCase(), 0));
}
}
