October 6th, 2024
What's missing in this code?
minSwaps('1100', '1001'); // 1
minSwaps('0011', '1100'); // 2
minSwaps('0000', '0000'); // 0
minSwaps('1011', '0111'); // 1
minSwaps('0101', '1010'); // 2
minSwaps('0101', '1010'); // 2
function minSwaps(s1, s2) {
return (
Array.from(
)
.map((s1i, i) => (
? 0 : 1))
.reduce((a, b) =>
) / 2
);
}
Type or select from these options