Java Solution
Replace all odd numbers with 1 and even with zeroes\n\nNow the problem becomes\nhttps://leetcode.com/problems/subarray-sum-equals-k/\n\nFind number of sub arrys
Replace all odd numbers with 1 and even with zeroes\n\nNow the problem becomes\n[https://leetcode.com/problems/subarray-sum-equals-k/](https://leetcode.com/problems/subarray-sum-equals-k/)\n\nFind number of sub arrys with sum = K\n```\npublic int numberOfSubarrays(int[] nums, int k) {\n         //Replace all odd by 1 and even by 0\n        for(int i=0;i<nums.length;i++){\n            nums[i] = (nums[i] %2 == 0) ? 0 : 1;\n        }\n        \n        //problem becomes number of subarrays with sum = k\n        HashMap<Integer,Integer> map = new HashMap<>();\n        int res = 0;\n        int sum = 0;//cumulative sum\n        map.put(0,1);\n        for(int i=0;i<nums.length;i++){\n            sum+=nums[i];\n            if(map.containsKey(sum - k)){\n                res+=map.get(sum - k);\n            }\n            map.put(sum,map.getOrDefault(sum,0)+1);\n        }\n        return res;\n    }\n```
[]