Skip to content

Commit bfde150

Browse files
committed
Runtime: 81 ms (Top 64.99%) | Memory: 42 MB (Top 44.71%)
1 parent 4c96a1f commit bfde150

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
// Runtime: 81 ms (Top 64.99%) | Memory: 42 MB (Top 44.71%)
12
const max=(x,y)=>x>y?x:y
23
var rob = function(nums) {
34
if(nums.length==1) return(nums[0]);
45
let temp=[]
56
temp[0]=nums[0];
67
temp[1]=max(nums[0],nums[1]);
7-
8+
89
for(let i =2;i<nums.length;i++){
910
temp[i] = max(temp[i-1],nums[i]+temp[i-2]);
1011
}
1112
// console.log(temp)
1213
return(temp[nums.length-1]);
13-
};
14+
};

0 commit comments

Comments
 (0)