Skip to content

Commit

Permalink
Implement house-robber-ii
Browse files Browse the repository at this point in the history
name: house-robber-ii
url: https://leetcode.com/problems/house-robber-ii
difficulty: 2

time: -1.0 ms
time-rank: -1 %
time-complexity: O(N)

space: -1.0 MB
space-rank: -1.0 %
space-complexity: O(N)

Fixes #303

Signed-off-by: Christopher Friedt <[email protected]>
  • Loading branch information
cfriedt committed Jan 14, 2021
1 parent 41b326c commit a58e733
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
26 changes: 26 additions & 0 deletions house-robber-ii-test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2021, Christopher Friedt
*
* SPDX-License-Identifier: MIT
*/

#include <gtest/gtest.h>

#include "house-robber-ii.cpp"

using namespace std;

TEST(HouseRobberIi, 2_3_2) {
vector<int> nums = {2, 3, 2};
EXPECT_EQ(3, Solution().rob(nums));
}

TEST(HouseRobberIi, 1_2_3_1) {
vector<int> nums = {1, 2, 3, 1};
EXPECT_EQ(4, Solution().rob(nums));
}

TEST(HouseRobberIi, 0) {
vector<int> nums = {0};
EXPECT_EQ(0, Solution().rob(nums));
}
20 changes: 20 additions & 0 deletions house-robber-ii.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2021, Christopher Friedt
*
* SPDX-License-Identifier: MIT
*/

// clang-format off
// name: house-robber-ii
// url: https://leetcode.com/problems/house-robber-ii
// difficulty: 2
// clang-format on

#include <vector>

using namespace std;

class Solution {
public:
int rob(vector<int> &nums) {}
};

0 comments on commit a58e733

Please sign in to comment.