{"size": 710, "ext": "js", "max_stars_repo_path": "91-decode-ways.js", "max_stars_repo_name": "parvezk/LeetCodeProblems", "max_stars_repo_stars_event_min_datetime": "2020-06-13T11:57:05.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-13T11:57:05.000Z", "max_issues_repo_path": "91-decode-ways.js", "max_issues_repo_name": "parvezk/LeetCodeProblems", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "91-decode-ways.js", "max_forks_repo_name": "parvezk/LeetCodeProblems", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.6666666667, "max_line_length": 50, "alphanum_fraction": 0.514084507}
/**
 * @param {string} s
 * @return {number}
 */
var numDecodings = function(s) {
    const memo = new Map() // {index, substring}
    
    const recursiveWithMemo = (index, str) => {
      
      if (index == s.length) return 1;
      
      if (str.charAt(index) == '0') return 0;
      
      if (index == s.length - 1) return 1;
      
      if (memo.has(index)) return memo.get(index);
      
      let ans = recursiveWithMemo(index + 1, str);
      if (+str.substring(index, index + 2) <= 26)
        ans += recursiveWithMemo(index + 2, str);
      
      memo.set(index, ans);
      return ans;
    }
    
    if (s == null || s.length == 0)
      return 0;
    
    return recursiveWithMemo(0, s);
  };