Skip to content

Instantly share code, notes, and snippets.

@titandino
Created December 1, 2016 19:14
Show Gist options
  • Save titandino/cfb00cf3c11fceb0255b9c93a6e0d413 to your computer and use it in GitHub Desktop.
Save titandino/cfb00cf3c11fceb0255b9c93a6e0d413 to your computer and use it in GitHub Desktop.
Consective increases
function numIncSections(arr) {
let num = 0;
if (arr.length <= 1)
return 0;
for(let i = 0;i < arr.length;i++) {
if (i >= arr.length)
break;
if (arr[i] < arr[i+1]) {
num++;
while(i < arr.length) {
if (arr[i] < arr[i+1]) {
i++;
} else {
break;
}
}
}
}
return num;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment