Tap here to switch tabs
Problem
Submissions

Problem: Longest Balanced Subarray I

Longest Balanced Subarray I asks you to find the longest contiguous part of an integer array where the number of distinct even values equals the number of distinct odd values.

Statement

You are given an integer array nums.

A subarray is defined as balanced if the count of distinct even numbers in the subarray is equal to the count of distinct odd numbers in the subarray.

Return the maximum length of a balanced subarray in nums.

Constraints:

  • 1≤1 \leq nums.length ≤1500\leq 1500

  • 1≤1 \leq nums[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Longest Balanced Subarray I

Longest Balanced Subarray I asks you to find the longest contiguous part of an integer array where the number of distinct even values equals the number of distinct odd values.

Statement

You are given an integer array nums.

A subarray is defined as balanced if the count of distinct even numbers in the subarray is equal to the count of distinct odd numbers in the subarray.

Return the maximum length of a balanced subarray in nums.

Constraints:

  • 1≤1 \leq nums.length ≤1500\leq 1500

  • 1≤1 \leq nums[i] ≤105\leq 10^5