|
1 | 1 | packagecom.fishercoder.solutions;
|
2 | 2 |
|
3 |
| -/** |
4 |
| - * 1248. Count Number of Nice Subarrays |
5 |
| - * |
6 |
| - * Given an array of integers nums and an integer k. A subarray is called nice if there are k odd numbers on it. |
7 |
| - * |
8 |
| - * Return the number of nice sub-arrays. |
9 |
| - * |
10 |
| - * Example 1: |
11 |
| - * Input: nums = [1,1,2,1,1], k = 3 |
12 |
| - * Output: 2 |
13 |
| - * Explanation: The only sub-arrays with 3 odd numbers are [1,1,2,1] and [1,2,1,1]. |
14 |
| - * |
15 |
| - * Example 2: |
16 |
| - * Input: nums = [2,4,6], k = 1 |
17 |
| - * Output: 0 |
18 |
| - * Explanation: There is no odd numbers in the array. |
19 |
| - * |
20 |
| - * Example 3: |
21 |
| - * Input: nums = [2,2,2,1,2,2,1,2,2,2], k = 2 |
22 |
| - * Output: 16 |
23 |
| - * |
24 |
| - * Constraints: |
25 |
| - * 1 <= nums.length <= 50000 |
26 |
| - * 1 <= nums[i] <= 10^5 |
27 |
| - * 1 <= k <= nums.length |
28 |
| - * */ |
29 | 3 | publicclass_1248 {
|
30 | 4 | publicstaticclassSolution1 {
|
31 | 5 | publicintnumberOfSubarrays(int[]nums,intk) {
|
32 | 6 | for (inti =0;i <nums.length;i++) {
|
33 | 7 | for (intj =0;j <nums.length;j++) {
|
34 |
| - |
| 8 | +//TODO: implement it |
35 | 9 | }
|
36 | 10 | }
|
37 | 11 | return -1;
|
|