46 return std::max(money[0], money[1]);
48 uint32_t max_value = 0;
49 uint32_t value1 = money[0];
50 uint32_t value2 = std::max(money[0], money[1]);
51 for (uint32_t i = 2; i < n; i++) {
52 max_value = std::max(money[i] + value1, value2);
69 std::vector<uint32_t> array1 = {1, 2, 3, 1};
70 std::cout <<
"Test 1... ";
72 dynamic_programming::house_robber::houseRobber(array1, array1.size()) ==
75 std::cout <<
"passed" << std::endl;
79 std::vector<uint32_t> array2 = {6, 7, 1, 3, 8, 2, 4};
80 std::cout <<
"Test 2... ";
82 dynamic_programming::house_robber::houseRobber(array2, array2.size()) ==
85 std::cout <<
"passed" << std::endl;
89 std::vector<uint32_t> array3 = {};
90 std::cout <<
"Test 3... ";
92 dynamic_programming::house_robber::houseRobber(array3, array3.size()) ==
94 std::cout <<
"passed" << std::endl;
98 std::vector<uint32_t> array4 = {2, 7, 9, 3, 1};
99 std::cout <<
"Test 4... ";
101 dynamic_programming::house_robber::houseRobber(array4, array4.size()) ==
104 std::cout <<
"passed" << std::endl;