Validate required settings

Write codeEasy10 min

Your task

A service refuses to boot unless certain settings exist. You get the config file as lines plus the list of required setting names (all distinct). Parse the lines: trim each; ignore empty ones and ones starting with "#"; split the rest at the first "=" with key and value trimmed; a name assigned several times keeps its last value. A requirement is satisfied only when the name was assigned AND its final value is non-empty after trimming. Return the unsatisfied names sorted alphabetically. Example: lines ["port=8080", "host="] with required ["port", "host"] returns ["host"].

Examples

missing_settings(lines: list[str], required: list[str]) -> list[str]
Example 1
Inputmissing_settings(["port=8080", "host="], ["port", "host", "token"])
Output["host", "token"]