• + 52 comments

    Well, sadly, this problem isn't really about sparse arrays or whatever intention was. It's silly. If you read this comment, then i'm pretty sure, you have the same opinion. I propose to have some fun! Let's write shortest/cleanest code which solves this stuff in our favourite languages. Here's my for java8 :P

        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            List<String> strings = IntStream.range(0, in.nextInt()).mapToObj(i -> in.next()).collect(Collectors.toList());
            IntStream.range(0, in.nextInt()).mapToObj(i -> in.next()).mapToLong(q -> strings.stream().filter(q::equals).count()).forEach(System.out::println);
        }