Minimum Steps
CodeChefOpen on judge ↗
You are given an array of size $N$, consisting only of -1 and 1.Your task is to make the sum of the array equals to 0. To make the sum 0, you can do $ONE$ of the following operation in $EACH$ step. - Replace -1 by 1. - Replace 1 by -1. Also, you will see that it's $Not$ always possible to make the sum 0, if it's impossible to make the sum 0, print $-1$ as a result. $Note :$ Arra
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start