Created
June 29, 2020 12:07
-
-
Save colombinis/c89a8ac1f414d6f2e39c02a3e4013b34 to your computer and use it in GitHub Desktop.
codility - encontrar mayor secuencia de 0 que inicien y finalizen con 1
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
| let contar=false; | |
| let contador=0; | |
| let ultima=0; | |
| "00001100100010000".split("").forEach((item)=>{ | |
| if(item == "1" && !contar){ | |
| contar=true; | |
| contador=0; | |
| }else if(item == "1" && contar) { | |
| if(ultima<contador){ | |
| ultima =contador; | |
| } | |
| contador=0; | |
| } | |
| if(contar && item == "0" ){ | |
| contador++; | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment