Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Readme.md

Two Sum Problem

Given a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1.

Example 1:

INPUT: nums = [0,1]
OUTPUT: 2
EXPLANATION: [0,1] is the longest contiguous subarray with equal number of 0 and 1.

Example 2:

INPUT: nums = [0,1,0]
OUTPUT: 2
EXPLANATION: [0,1] (or [1,0]) is the longest contiguous subarray with equal number of 0 and 1.

Constraints:

  • 1 <= nums.length <= 10^5
  • nums[i] is either 0 or 1