Skip to content

Instantly share code, notes, and snippets.

@OlivierJM
Created August 6, 2021 08:01
Show Gist options
  • Save OlivierJM/e46cdcd5378f4a4cf9eb719e2b426195 to your computer and use it in GitHub Desktop.
Save OlivierJM/e46cdcd5378f4a4cf9eb719e2b426195 to your computer and use it in GitHub Desktop.
function countingValleys(steps, path) {
for (let index = 0; index < steps; index++) {
const currentStep = path[index];
const nextStep = path[index + 1];
let downHill = 0;
let upHill = 0;
if (currentStep + nextStep !== "UD") {
if (currentStep === nextStep) {
// we are either going downhill or uphill
// now check if currentStep is D which means downhil, if U then upHill
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment