<commit_before>package com.fishercoder.solutions;

import java.util.HashMap;
import java.util.Map;

public class _325 {

    public static class Solution1 {
        public int maxSubArrayLen(int[] nums, int k) {
            Map<Integer, Integer> map = new HashMap();
            int sum = 0;
            int max = 0;
            for (int i = 0; i < nums.length; i++) {
                sum += nums[i];
                if (sum == k) {
                    max = i + 1;
                } else if (map.containsKey(sum - k)) {
                    max = Math.max(max, i - map.get(sum - k));
                }
                if (!map.containsKey(sum)) {
                    map.put(sum, i);
                }
            }
            return max;
        }
    }

}<commit_msg>refactor 325<commit_after>package com.fishercoder.solutions;

import java.util.HashMap;
import java.util.Map;

public class _325 {

    public static class Solution1 {
        /**
         * 1. This is a beautiful and classic solution that combines prefix sum and hashmap for quick search;
         * 2. This actually covers all possible cases and could find the maximum array size
         */
        public int maxSubArrayLen(int[] nums, int k) {
            Map<Integer, Integer> map = new HashMap();
            int sum = 0;
            int max = 0;
            for (int i = 0; i < nums.length; i++) {
                sum += nums[i];
                if (sum == k) {
                    max = i + 1;
                } else if (map.containsKey(sum - k)) {
                    max = Math.max(max, i - map.get(sum - k));
                }
                if (!map.containsKey(sum)) {
                    map.put(sum, i);
                }
            }
            return max;
        }
    }

}
{'fraction_non_alphanumeric': 0.10991501416430595, 'fraction_numerical': 0.01189801699716714, 'mean_word_length': 1.2354430379746835, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6074194', 'n_tokens_mistral': 532, 'n_tokens_neox': 494, 'n_words': 152}