{"size": 1061, "ext": "js", "max_stars_repo_path": "Front-end/JS Fundamentals Contests/1/1. Hills/hills-climb-or-not.js", "max_stars_repo_name": "petyakostova/Telerik-Academy", "max_stars_repo_stars_event_min_datetime": "2015-11-20T00:32:42.000Z", "max_stars_repo_stars_event_max_datetime": "2018-04-26T20:16:36.000Z", "max_issues_repo_path": "Front-end/JS Fundamentals Contests/1/1. Hills/hills-climb-or-not.js", "max_issues_repo_name": "petyakostova/Telerik-Academy", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Front-end/JS Fundamentals Contests/1/1. Hills/hills-climb-or-not.js", "max_forks_repo_name": "petyakostova/Telerik-Academy", "max_forks_repo_forks_event_min_datetime": "2016-04-05T06:30:28.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-19T20:01:04.000Z"}
{"max_stars_count": 15, "max_issues_count": null, "max_forks_count": 17, "avg_line_length": 27.9210526316, "max_line_length": 84, "alphanum_fraction": 0.4806786051}
function solve(args) {
    'use strict';
    let heights = args[0].split(' ').map(Number),
        bestCount = -1,
        count = 0,
        climbDown = true,
        current = heights[0];

    // to catch if the last valley is with best rocks count => must start climb down
    heights.push(-1);

    for (let i = 1; i < heights.length; i += 1) {
        let height = heights[i];

        if (climbDown) {
            // stop climb down => start to climbing
            if (current < height) {
                climbDown = false;
            }
        } else { // climbing
            // stop climb => start climb down
            if (current > height) {
                bestCount = Math.max(bestCount, count); // save count
                count = 0; // reset count
                climbDown = true; // climbDown = !climbDown;
            }
        }
        
        current = height; // update current        
        count += 1;
    }

    console.log(bestCount);
}

solve(['5 1 7 4 8']);
solve(['5 1 7 6 3 6 4 2 3 8']);
solve(['10 1 2 3 4 5 4 3 2 1 10']);