A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com", and at the lowest level, "discuss.leetcode.com".
When we visit a domain like "discuss.leetcode.com", we will also visit its parent domains "leetcode.com" and "com" implicitly.
A count-paired domain is a domain that has a visit count paired with it, e.g. "9001 discuss.leetcode.com".
Given an array of count-paired domains cpdomains, return an array of the count-paired domains of each subdomain. The output can be in any order.
cpdomains = ["9001 discuss.leetcode.com"]["9001 discuss.leetcode.com", "9001 leetcode.com", "9001 com"]cpdomains = ["900 google.mail.com", "50 yahoo.com", "1 intel.mail.com", "5 wiki.org"]["901 mail.com", "50 yahoo.com", "900 google.mail.com", "1 intel.mail.com", "5 wiki.org", "5 org", "951 com"]1 <= cpdomains.length <= 1001 <= cpdomains[i].length <= 100cpdomains[i] follows the format "count domain"1 <= count <= 10^4Each domain has either 1 or 2 dots.Run your code to see results
Use Cmd+Enter to run