JAVA || Picture + Detail Explanation || prefix sum + HashMap || Easy Solution
\n\n In this problem , First we will change the odd digit from 1 and even with zero in given array.\n then we use the same approach which we used in the leetcod
![image](https://assets.leetcode.com/users/images/27b0cd6e-ffd3-4eca-8787-6b8d0b15b43f_1634763142.2267573.png)\n\n* In this problem , First we will change the odd digit from 1 and even with zero in given array.\n* then we use the same approach which we used in the leetcode problem 560. If you want detail explanation then ->\nHere is the link of the problem \n[https://leetcode.com/problems/subarray-sum-equals-k/discuss/1532102/java-picture-explanation-2-methods-prefix-sum-hashmap-easy-solution]\n\n```\n  public int numberOfSubarrays(int[] nums, int k) {\n   \n     int s=0,e=nums.length;\n   \n    for(int i=0;i<e;i++){\n        if(nums[i]%2!=0){\n            nums[i]=1;\n        }else{\n            nums[i]=0;\n        }\n    }\n      \n       Map<Integer,Integer> p = new HashMap();\n        \n     p.put(0,1);   \nint ans=0,sum=0;\n        \n     for(int i=0;i<nums.length;i++){\n         sum+=nums[i];\n        if(p.containsKey(sum-k)){\n            ans+=p.get(sum-k);\n        } \n         p.put(sum,p.getOrDefault(sum,0)+1);\n     }   \n       return ans; \n        \n    }\n```\n\nif you like it , then please upvote it
['Sliding Window', 'Prefix Sum', 'Java']