[JAVA] simple O(n) solution
\nclass Solution {\n    public int numberOfSubarrays(int[] nums, int k) {\n        ArrayList<Integer> pos = new ArrayList<>();\n        pos.add(0);\n        for
```\nclass Solution {\n    public int numberOfSubarrays(int[] nums, int k) {\n        ArrayList<Integer> pos = new ArrayList<>();\n        pos.add(0);\n        for(int i=0;i<nums.length;i++){\n            if(nums[i]%2==1){\n                pos.add(i+1);\n            }\n        }\n        pos.add(nums.length+1);\n        int res=0;\n\n        for(int i=1;i<=pos.size()-k-1;i++){\n            int start=pos.get(i)-pos.get(i-1);\n            int end = pos.get(i+k)-pos.get(i+k-1);\n            res+=start*end;\n        }\n        return res;\n    }\n}\n```
['Java']