package leetcode;

import java.util.List;

/**
 * https://leetcode.com/problems/subdomain-visit-count/description/
 */
public class Problem811 {
    public List<String> subdomainVisits(String[] cpdomains) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem811 prob = new Problem811();
        System.out.println(prob.subdomainVisits(new String[]{"9001 discuss.leetcode.com"})); // ["9001 discuss.leetcode.com", "9001 leetcode.com", "9001 com"]
        System.out.println(prob.subdomainVisits(new String[]{"900 google.mail.com", "50 yahoo.com", "1 intel.mail.com", "5 wiki.org"})); // ["901 mail.com","50 yahoo.com","900 google.mail.com","5 wiki.org","5 org","1 intel.mail.com","951 com"]

    }
}

@@ -33,13 +33,89 @@
 til.
+Array
 List;
+%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;
 %0A%0A/*
@@ -288,536 +288,808 @@
     
-// TODO%0A        return null;
+Map%3CString, Integer%3E map = new HashMap%3C%3E();%0A        for (String cpdomain : cpdomains) %7B
 %0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem811 prob = new Problem811();%0A        System.out.println(prob.subdomainVisits(new String%5B%5D%7B%229001 discuss.leetcode.com%22%7D)); // %5B%229001 discuss.leetcode.com%22, %229001 leetcode.com%22, %229001 com%22%5D%0A        System.out.println(prob.subdomainVisits(new String%5B%5D%7B%22900 google.mail.com%22, %2250 yahoo.com%22, %221 intel.mail.com%22, %225 wiki.org%22%7D)); // %5B%22901 mail.com%22,%2250 yahoo.com%22,%22900 google.mail.com%22,%225 wiki.org%22,%225 org%22,%221 intel.mail.com%22,%22951 com%22%5D%0A
+    String%5B%5D split = cpdomain.split(%22 %22);%0A            int count = Integer.parseInt(split%5B0%5D);%0A            String domain = split%5B1%5D;%0A            String%5B%5D d = domain.split(%22%5C%5C.%22);%0A            String str = %22%22;%0A            for (int i = d.length - 1; i %3E= 0; i--) %7B%0A                str = d%5Bi%5D + ((str.isEmpty()) ? %22%22 : %22.%22) + str;%0A                if (map.containsKey(str)) %7B%0A                    map.put(str, map.get(str) + count);%0A                %7D else %7B%0A                    map.put(str, count);%0A                %7D%0A            %7D%0A        %7D%0A        List%3CString%3E result = new ArrayList%3C%3E();%0A        map.forEach((domain, count) -%3E %7B%0A            result.add(count + %22 %22 + domain);%0A        %7D);%0A        return result;
 %0A   

Solve problem 811