User agent browser detection
Extract the browser family and major version from a simplified User-Agent string. Look for the first token of the form Name/Version where Name is one of Chrome, Firefox, Safari, or Edge and Version starts with an integer major number. Return [name, major_version] with major_version as an int. If no recognized browser token is found, return ["unknown", -1].
Implement
parse_user_agent(ua: str) → listExamples
in
["Mozilla/5.0 Chrome/118.0.5993.88 Safari/537.36"]out["Chrome",118]What a strong answer looks like
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.
0:00 of about 15 min
solution.py
InputExpectedGot
["Mozilla/5.0 Chrome/118.0.5993.88 Safari/537.36"]["Chrome",118]not run yetsample