JS Solution
Simple recurse JS Solution\n\n# Code\n\n/**\n * @param {number[]} locations\n * @param {number} start\n * @param {number} finish\n * @param {number} fuel\n * @r
Simple recurse JS Solution\n\n# Code\n```\n/**\n * @param {number[]} locations\n * @param {number} start\n * @param {number} finish\n * @param {number} fuel\n * @return {number}\n */\nvar count = (locations,start,finish,fuel,dp)=>{\n    let mod=Math.pow(10,9)+7;\n    if(fuel<0)\n        return 0;\n    if(dp[start][fuel]!=-1){\n        return dp[start][fuel];\n    }\n    let ret=0;\n    let len = locations.length;\n    for(let i=0;i<len;i++){\n        if(i==start)\n            continue;\n        ret+=count(locations,i,finish,fuel-Math.abs(locations[i]-locations[start]),dp)%mod;\n    }\n    if(start==finish){\n        ret++;\n    }\n    dp[start][fuel]=ret;\n    return ret%mod;\n}\nvar countRoutes = function(locations, start, finish, fuel) {\n    let len = locations.length;\n    let dp = new Array(len+1);\n    for(let i=0;i<=len;i++){\n        dp[i] = new Array(fuel+1).fill(-1);\n    }\n    console.log(dp);\n    return count(locations,start,finish,fuel,dp);\n};\n```
['JavaScript']