Subdomain Visit Count
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
A domain such as "mail.example.com" is made of dot-separated labels. Visiting it also counts as a visit to each of its parent domains: "example.com" and "com".
You are given cpdomains, where each entry has the form "<count> <domain>", meaning domain was visited count times. The same domain may appear in more than one entry.
Return one string "<total> <domain>" for every domain or parent domain that received at least one visit, where total is its total visit count. The strings may be returned in **any order**.
Examples
Constraints
- `1 <= cpdomains.length <= 100`
- `1 <= cpdomains[i].length <= 100`
- Each entry is `"<count> <domain>"` with `1 <= count <= 10^4`
- Each domain has 1 to 3 labels of lowercase English letters joined by `.`
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.