This is a verified interview question from Jefeeerirs. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Minimum Flips to Equalize Zeros and Ones - Jefeeerirs Online Assessment IIT Delhi" covers key patterns like Arrays.
"Pattern: 3 DSA + 18 -20 MCQS You are given a binary array **arr** of size **N**, consisting only of **0s** and **1s**. In one operation, you may **flip any single element**, i.e.: * `0 → 1` * `1 → 0` Find the **minimum number of flips** required so that the number of **0s** and **1s** in the array becomes equal. If it is impossible, print **-1**. --- ### Input Format * The first line contains an integer **N**. * The second line contains **N** space-separated integers (`0` or `1`). --- ### Output Format Print a single integer representing the minimum number of flips required. --- ### Constraints * (1 <= N <= 10^5) --- ### Example 1 #### Input ```text 6 1 1 1 0 0 0 ``` #### Output ```text 0 ``` --- ### Example 2 #### Input ```text 8 1 1 1 1 0 0 0 0 ``` #### Output ```text 0 ``` --- ### Example 3 #### Input ```text 6 1 1 1 1 1 0 ``` #### Output ```text 2 ``` --- ### Example 4 #### Input ```text 5 1 1 0 0 1 ``` #### Output ```text -1 ```"
Join thousands of developers practicing for Jefeeerirs.