Subdomain Visit Count
1. A website domain like "www.pepcoding.com" consists of various subdomains like "com" at the topmost level, "pepcoding.com" at the next level, and "www.pepcoding.com" at the lowest level. 2. When you visit a domain like "www.pepcoding.com", you will also visit its parent domains "pepcoding.com" and "com". 3. You are given N number of strings where every string contains a number and a domain separated by a space, where the number represents the visit count of the domain. 4. You have to find the number of visits for each sub-domain.
1 <= N <= 100 1 <= visit count of a domain <= 10^4 1 <= length of domain name <= 100 Each address will contain at most 2 "." characters.
A number N N strings. Each string contains a number and domain.
Every line of output contains a number and a sub-domain, where the number represents the visit count of the sub-domain.
1 9999 www.pepcoding.com
9999 com 9999 pepcoding.com 9999 www.pepcoding.com