As reported: Rubrik online assessment (2026).
You are given a binary string s (only '0' and '1'). In one swap you may exchange any two characters — they need not be adjacent.
Return the minimum number of swaps needed to make s a palindrome, or -1 if it is impossible.
Example 1
s = "101000" -> 1
Swap the characters at positions 2 and 5 (1-indexed): "100001".
Example 2
s = "10" -> -1
Constraints: 1 ≤ s.length ≤ 10^5.
Code runner format: one line holding s as a JSON string. Implement minSwaps(s); the harness prints the answer.