Created
October 23, 2021 00:10
-
-
Save germanescobar/9c45e4142c72efc8a2ce6ad5533734a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var minFlips = function(target) { | |
let count = 0 | |
for (i=0; i < target.length; i++) { | |
if (parseInt(target[i]) !== count % 2) count++ | |
} | |
return count | |
} | |
// se queda por límite de tiempo. | |
var minFlips = function(target) { | |
let current = [] | |
for (let i=0; i < target.length; i++) { | |
current[i] = "0" | |
} | |
let count = 0 | |
for (i=0; i < target.length; i++) { | |
if (target[i] !== current[i]) { | |
flip(current, i) | |
count++ | |
} | |
} | |
return count | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment