Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make Binary Array All Ones II

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

Statement

You are given a binary array nums.

In one operation, you can choose any index i and flip every element from index i to the end of the array (changing every 00 to 11 and every 11 to 00).

Return the minimum number of operations required to make all elements in nums equal to 11.

Constraints:

  • 1≤1 \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 II

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

Statement

You are given a binary array nums.

In one operation, you can choose any index i and flip every element from index i to the end of the array (changing every 00 to 11 and every 11 to 00).

Return the minimum number of operations required to make all elements in nums equal to 11.

Constraints:

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

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