Tap here to switch tabs
Problem
Submissions

Problem: Count Subarrays With Even Odd Ratio II

Try to solve the Count Subarrays With Even Odd Ratio II problem.

Statement

Given an array of integers nums and two integers a and b, return the total number of valid subarrays.

A subarray is defined as valid if both of the following conditions are satisfied:

  1. It contains at least 11 odd integer.

  2. The ratio of the number of even integers to the number of odd integers in the subarray does not exceed ab\frac{a}{b} (that is, evencountoddcount≤ab\frac{ {even count}}{ {odd count}} \le \frac{a}{b}).

Constraints:

  • 1≤1 \le nums.length ≤105\le 10^5

  • 1≤1 \le nums[i] ≤109\le 10^9

  • 1≤1 \le a, b ≤109\le 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Subarrays With Even Odd Ratio II

Try to solve the Count Subarrays With Even Odd Ratio II problem.

Statement

Given an array of integers nums and two integers a and b, return the total number of valid subarrays.

A subarray is defined as valid if both of the following conditions are satisfied:

  1. It contains at least 11 odd integer.

  2. The ratio of the number of even integers to the number of odd integers in the subarray does not exceed ab\frac{a}{b} (that is, evencountoddcount≤ab\frac{ {even count}}{ {odd count}} \le \frac{a}{b}).

Constraints:

  • 1≤1 \le nums.length ≤105\le 10^5

  • 1≤1 \le nums[i] ≤109\le 10^9

  • 1≤1 \le a, b ≤109\le 10^9