Subdomain Visit Count

easy
1.A website domain like "mail.google.com" consists of various subdomains.
 2.At the top level, we have "com", at the next level, we have "google.com" 
   and at the lowest level, "mail.google.com".
 3.When we visit a domain like "mail.google.com", we will also visit the parent domains
   "google.com" and "com" implicitly.
 4.Count-paired domain is a count (representing the number of visits this domain received)
   followed by a space, followed by the address.
   An example of a count-paired domain might be "9001 mail.google.com".
 5.You are given a list cpdomains of count-paired domains. 
 6.You need to return a list of count-paired domains, (in the same format as the input, and in any order)
   that explicitly counts the number of visits to each subdomain.
 7.You have to complete the function subdomainVisits() to return the desired list.

Input Format

1.First line contains an integer 'N' denoting the size of the cpdomains array. 2.Next 'N' lines contains strings representing cpdomains.

Output Format

1.Return the desired list of string. 2.The answer output can be returned in any order.

Constraints

1.Each address will have either 1 or 2 "." characters.
 2.The input count in any count-paired domain will not exceed 10000

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
4
900 google.mail.com
50 yahoo.com
1 intel.mail.com
5 wiki.org
Output
[1 intel.mail.com, 5 org, 5 wiki.org, 50 yahoo.com, 900 google.mail.com, 901 mail.com, 951 com]
Previous
Double Pair Array
Next
Group Anagrams

Related Questions