@@ -0,0 +1,1504 @@
+/**%0A * Company%0A * Copyright (C) 2014-2017 All Rights Reserved.%0A */%0Apackage com.cwenao.trying;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0A/**%0A * find the serial sub-array when the sum is 0%0A * %E6%AD%A4%E9%A2%98%E6%89%BE%E7%9A%84%E6%98%AF%E8%BF%9E%E7%BB%AD%E7%9A%84%E6%95%B0%E7%BB%84%EF%BC%8C%E6%9C%80%E5%BC%80%E5%A7%8B%E5%9C%A8%E6%8E%A8%E7%AE%97%E6%AD%A4%E5%86%99%E6%B3%95%E7%9A%84%E4%B8%80%E7%9B%B4%E6%98%AF%E8%AE%A4%E4%B8%BA%E9%94%99%E8%AF%AF%EF%BC%8C%E6%89%93%E7%AE%97%E6%94%B9%E5%86%99%0A * %E6%9C%80%E5%90%8E%E5%9C%A8%E7%A4%BA%E4%BE%8B%E4%B8%AD%E7%9C%8B%E5%88%B0%E8%8E%B7%E5%8F%96%E7%9A%84sub-array%E6%98%AF%E8%BF%9E%E7%BB%AD%E6%95%B0%E7%BB%84%0A * @author cwenao%0A * @version $Id SubArraysByMultimap.java, v 0.1 2017-06-24 10:05 cwenao Exp $$%0A */%0Apublic class SubArraysByMultimap %7B%0A%0A    private static void insertMap(Map%3CInteger, List%3CInteger%3E%3E hashMap,%0A                                  Integer key, Integer index) %7B%0A        if (hashMap.containsKey(key)) %7B%0A            hashMap.get(key).add(index);%0A        %7D else %7B%0A            List%3CInteger%3E list = new ArrayList%3C%3E();%0A            list.add(index);%0A            hashMap.put(key, list);%0A        %7D%0A%0A    %7D%0A%0A    private static void resolveArray(int%5B%5D array) %7B%0A%0A        Map%3CInteger, List%3CInteger%3E%3E hashMap = new HashMap%3C%3E();%0A        int sum = 0;%0A        insertMap(hashMap,sum, -1);%0A%0A        for(int i =0;i%3Carray.length;i++) %7B%0A            sum += array%5Bi%5D;%0A%0A            if (hashMap.containsKey(sum)) %7B%0A                List%3CInteger%3E list = hashMap.get(sum);%0A                for (Integer x : list) %7B%0A                    System.out.println(%22Sub-array%5B%22 + (x + 1) + %22..%22 + i + %22%5D%22);%0A                %7D%0A            %7D%0A            insertMap(hashMap,sum,i);%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        int%5B%5D x = %7B3, 4, -7, 3, 1, 3, 1, -4, -2, -2%7D;%0A        resolveArray(x);%0A    %7D%0A%0A%7D

add the sec