Created
October 11, 2017 00:15
-
-
Save rubcuadra/66446037374aff2d238eddef1bf5f889 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
//Recibe un arreglo | |
function buscaMayor(a){ | |
//Para regresar | |
var f = 0; | |
var l = 0; | |
//Temporales | |
var tc = f; | |
var te = l; | |
//Iterar | |
for (var i = 1; i < a.length; i++) { | |
if (a[i-1]<=a[i]) | |
{ | |
te++; | |
} | |
else | |
{ | |
if (l-f < te-tc) | |
{ | |
f = tc; | |
l = te; | |
} | |
tc = te = i; | |
} | |
} | |
return {size:l-f+1,elements:a.slice(f,l+1)}; | |
} | |
function useless(callback, params){ return callback(params); } | |
var result = [1,2,2,4]; | |
var evalua = useless( buscaMayor, [6,5,1,2,2,4,1,3,2] ); | |
assert( result.length === evalua.size, "Busca Mayor desde useless funciona!" ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment