Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make Binary Array All Ones I

Try to solve the Minimum Operations to Make Binary Array All Ones I problem.

Statement

You are given a binary array nums.

In one operation, you can choose any 33 consecutive elements from nums and flip each of them, changing every 00 to 11 and every 11 to 00.

Return the minimum number of operations required to make every element in nums equal to 11. If it is impossible to make all elements equal to 11, return −1-1.

Constraints:

  • 3≤3 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤1\leq 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make Binary Array All Ones I

Try to solve the Minimum Operations to Make Binary Array All Ones I problem.

Statement

You are given a binary array nums.

In one operation, you can choose any 33 consecutive elements from nums and flip each of them, changing every 00 to 11 and every 11 to 00.

Return the minimum number of operations required to make every element in nums equal to 11. If it is impossible to make all elements equal to 11, return −1-1.

Constraints:

  • 3≤3 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤1\leq 1