Tap here to switch tabs
Problem
Submissions

Problem: Widest Pair of Indices With Equal Range Sum

Try to solve the Widest Pair of Indices With Equal Range Sum problem.

Statement

You are given two 00 indexed binary arrays nums1 and nums2, both of length n.

A pair of indices (i, j) is considered valid if 0≤i≤j<n0 \leq i \leq j < n and the sum of the elements from index i to index j inclusive in nums1 is equal to the sum of the elements from index i to index j inclusive in nums2.

The distance between the pair of indices (i, j) is defined as j−i+1j - i + 1.

Return the maximum distance of a valid pair of indices (i, j). If there are no valid pairs of indices, return 00.

Constraints:

  • n ==== nums1.length ==== nums2.length

  • 1≤1 \leq n ≤105\leq 10^5

  • nums1[i] is either 00 or 11.

  • nums2[i] is either 00 or 11.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Widest Pair of Indices With Equal Range Sum

Try to solve the Widest Pair of Indices With Equal Range Sum problem.

Statement

You are given two 00 indexed binary arrays nums1 and nums2, both of length n.

A pair of indices (i, j) is considered valid if 0≤i≤j<n0 \leq i \leq j < n and the sum of the elements from index i to index j inclusive in nums1 is equal to the sum of the elements from index i to index j inclusive in nums2.

The distance between the pair of indices (i, j) is defined as j−i+1j - i + 1.

Return the maximum distance of a valid pair of indices (i, j). If there are no valid pairs of indices, return 00.

Constraints:

  • n ==== nums1.length ==== nums2.length

  • 1≤1 \leq n ≤105\leq 10^5

  • nums1[i] is either 00 or 11.

  • nums2[i] is either 00 or 11.