{"size": 315, "ext": "js", "max_stars_repo_path": "Easy/house_robber.js", "max_stars_repo_name": "ee06b056/TopInterviewQuestions", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Easy/house_robber.js", "max_issues_repo_name": "ee06b056/TopInterviewQuestions", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Easy/house_robber.js", "max_forks_repo_name": "ee06b056/TopInterviewQuestions", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.2307692308, "max_line_length": 61, "alphanum_fraction": 0.4761904762}
/**
 * @param {number[]} nums
 * @return {number}
 */
var rob = function(nums) {
    let ans = 0;
    const dp = (new Array(nums.length + 2)).fill(0);
    for (let i = 2; i < dp.length; i++) {
        dp[i] = Math.max(dp[i - 1], dp[i - 2] + nums[i - 2]);
        ans = Math.max(ans, dp[i]);
    }
    return ans;
};