We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c2732d3 commit 19a792eCopy full SHA for 19a792e
problems/198.house-robber.md
@@ -179,13 +179,13 @@ class Solution {
179
if (length == 1) {
180
return nums[0];
181
}
182
- int first = nums[0], second = Math.max(nums[0], nums[1]);
+ int prev = nums[0], cur = Math.max(nums[0], nums[1]);
183
for (int i = 2; i < length; i++) {
184
- int temp = second;
185
- second = Math.max(first + nums[i], second);
186
- first = temp;
+ int temp = cur;
+ cur = Math.max(prev + nums[i], cur);
+ prev = temp;
187
188
- return second;
+ return cur;
189
190
191
```
0 commit comments