NeetCode #769LC-3191MediumGreedy
← Back to All Problems#769 · #3191 · Minimum Operations to Make Binary Array Elements Equal to One I(使二进制数组全部等于 1 的最少操作次数 I)
📌 Problem Statement & Constraints
Given a binary array
nums, an operation chooses an index i <= n - 3 and flips nums[i], nums[i+1] and nums[i+2]. Return the minimum operations to make all elements 1, or -1 if impossible. Constraints: 3 <= nums.length <= 10^5, nums[i] is 0 or 1.🔒
Sign In to Unlock Full Solutions for All 973 Problems
Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!