public class Solution {
    public boolean checkSubarraySum(int[] nums, int k) {
        if(nums == null || nums.length == 0){
            return false;
        }

        for(int i=0; i<nums.length ; i++){
            int sum = nums[i];
            for(int j= i+1 ; j<nums.length;j++){
                sum = sum+ nums[j];
                if(k!= 0 && isMultiple(sum,k)){
                    return true;
                }else{
                    if(k == 0){
                        if(sum == 0){
                            return true;
                        }
                    }
                }
            }
        }
        return false;
    }
    
    private boolean isMultiple(int sum, int k){
        return sum%k==0;
    }
}
@@ -732,10 +732,535 @@
 0;%0A    %7D
+%0A%0A    public boolean checkSubarraySum2(int%5B%5D nums, int k)%7B%0A        Map%3CInteger, Integer%3E map = new HashMap%3CInteger,Integer%3E();%0A        map.put(0,-1);%0A        int runningSum = 0;%0A        for(int i=0;i%3Cnums.length;i++)%7B%0A            runningSum += nums%5Bi%5D;%0A            if(k!= 0)%7B%0A                runningSum %25=k;%0A            %7D%0A            Integer pre = map.get(runningSum);%0A            if( pre != null && i-pre%3E1)%7B%0A                return true;%0A            %7D%0A            map.put(runningSum,i);%0A        %7D%0A        return false;%0A    %7D
 %0A%7D

Add O(n) solution