Skip to content

Commit 0d6ab88

Browse files
committed
Add Q198
1 parent f043283 commit 0d6ab88

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

198_HouseRobber/HouseRobber.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public:
3+
int rob(vector<int>& nums) {
4+
int n = 0, y = 0;
5+
for (auto&& num : nums) {
6+
int t = n;
7+
n = max(n, y);
8+
y = num + t;
9+
}
10+
return max(n,y);
11+
}
12+
};

0 commit comments

Comments
 (0)