Search⌘ K
AI Features

Minimum Swaps to Group All 1's Together II

Try to solve the Minimum Swaps to Group All 1's Together II problem.

We'll cover the following...

Statement

Given a binary circular array nums, you may perform swaps of any two elements in nums. Return the minimum number of swaps needed to make all values equal to 1 appear in a single contiguous block (considering the circular wrap around).

Note: Since nums is circular, a contiguous block of 1s may wrap from the end of the array to the beginning.

Constraints:

  • ...