Code Room
CodingEasycod-g1038
Subject Networking user agentLevel Entry–Mid~15 minCommon in Networking & APIs · Algorithms & data structures interviewsIndustries Software development

Question

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) → list
Examples
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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.