Tap here to switch tabs
Problem
Submissions

Problem: Subdomain Visit Count

med
30 min
Try to solve the Subdomain Visit Count problem.

Statement

A website domain such as "discuss.leetcode.com" consists of various subdomains. At the highest level, there is "com", at the next level, there is "leetcode.com", and at the lowest level, there is "discuss.leetcode.com". When a domain such as "discuss.leetcode.com" is visited, each of its parent subdomains, "leetcode.com" and "com", is visited implicitly as well.

A count pair domain is a string formatted as "rep d1.d2.d3" or "rep d1.d2", where rep specifies the number of visits to that domain, and the remainder represents the domain itself.

Given an array of count pair domain strings cpdomains, return an array of the count pair domains representing each subdomain visited in the input. The result may be returned in any order.

Constraints:

  • 1≤1 \leq cpdomain.length ≤100\leq 100

  • 1≤1 \leq cpdomain[i].length ≤100\leq 100

  • cpdomain[i] follows either the "rep_i d1_i.d2_i.d3_i" format or the "rep_i d1_i.d2_i" format.

  • rep_i is an integer in the range [1,104][1, 10^4].

  • d1_i, d2_i, and d3_i consist of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Subdomain Visit Count

med
30 min
Try to solve the Subdomain Visit Count problem.

Statement

A website domain such as "discuss.leetcode.com" consists of various subdomains. At the highest level, there is "com", at the next level, there is "leetcode.com", and at the lowest level, there is "discuss.leetcode.com". When a domain such as "discuss.leetcode.com" is visited, each of its parent subdomains, "leetcode.com" and "com", is visited implicitly as well.

A count pair domain is a string formatted as "rep d1.d2.d3" or "rep d1.d2", where rep specifies the number of visits to that domain, and the remainder represents the domain itself.

Given an array of count pair domain strings cpdomains, return an array of the count pair domains representing each subdomain visited in the input. The result may be returned in any order.

Constraints:

  • 1≤1 \leq cpdomain.length ≤100\leq 100

  • 1≤1 \leq cpdomain[i].length ≤100\leq 100

  • cpdomain[i] follows either the "rep_i d1_i.d2_i.d3_i" format or the "rep_i d1_i.d2_i" format.

  • rep_i is an integer in the range [1,104][1, 10^4].

  • d1_i, d2_i, and d3_i consist of lowercase English letters.