Match wildcard certificates
An edge proxy checks whether it already holds a certificate for an arriving request. patterns lists the hostnames the installed certificates cover, and hosts lists the hostnames requests came in on. A hostname is one or more labels joined by dots, and every label is a non empty run of lowercase letters, digits or hyphens. The leftmost label of a pattern may be exactly one asterisk. No other label of a pattern is an asterisk, and no host carries one. A pattern with no asterisk covers a host only when the two read identically. A wildcard pattern covers a host when the host has the same number of labels and every label after the leftmost is identical, so "*.example.com" covers "api.example.com" but covers neither "example.com" nor "eu.api.example.com". Return one boolean per host, in the order given, true when at least one pattern covers that host.
cert_host_coverage(patterns: list[str], hosts: list[str]) → list[bool][["*.example.com","example.com"],["api.example.com","example.com","eu.api.example.com","example.org"]]out[true,true,false,false][["cdn-1.assets.net","*.assets.net"],["cdn-1.assets.net","cdn-2.assets.net","assets.net"]]out[true,true,false]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[["*.example.com","example.com"],["api.example.com","example.com","eu.api.example.com","example.org"]][true,true,false,false]not run yetsample[["cdn-1.assets.net","*.assets.net"],["cdn-1.assets.net","cdn-2.assets.net","assets.net"]][true,true,false]not run yetsample