Skip to content

Instantly share code, notes, and snippets.

@germanescobar
Created October 23, 2021 00:10
Show Gist options
  • Save germanescobar/9c45e4142c72efc8a2ce6ad5533734a3 to your computer and use it in GitHub Desktop.
Save germanescobar/9c45e4142c72efc8a2ce6ad5533734a3 to your computer and use it in GitHub Desktop.
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