Senior Software Engineer @HCL TECH | Ex-Infoscion | Building Secure and Scalable Softwares | Full Stack Developer
🚀 Leetcode Daily Challenge 📅 14th Mar 2024 Post Part-II (Intuition and Solution) Intuition: 1. As we iterate through the array, we maintain a running sum currSum. 2. The idea behind using a hashmap is to keep track of the frequencies of cumulative sums encountered so far. 3. Whenever currSum - goal is found in the hashmap, it means there exists a subarray whose sum is goal. We add the frequency of currSum - goal to the subarray_count. 4. By updating the hashmap with the current sum's frequency, we are essentially building a record of cumulative sums encountered so far. #comment the Time Complexity and Space Complexity for this approach. #dailycodingchallenge #leetcode #problem #solution