• + 0 comments

    Perl:

    sub matchingStrings {
        my ($strings, $queries) = @_;
        
        my %h;
        my @res;
        foreach (@$strings) {
            $h{$_} +=1;
        }
        foreach my $el (@$queries) {
            if ($h{$el}) {
                push(@res, $h{$el});
            } else {
                push(@res, 0);
            }
            
        }    
        return @res;
    }