#3666

Minimum Operations to Equalize Binary String

candidate master · 1560 · lc hard +32 · 45.4% accepted · 300 likes · top 29%

Description

Given a binary string s and integer k, each operation selects exactly k distinct indices and flips every character at those positions. Find the minimum number of operations to make every character '1', or return -1 if it is impossible.

Code

1
2
3