A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d6/d26/house__robber_8cpp_source.html below:

TheAlgorithms/C++: dynamic_programming/house_robber.cpp Source File

Go to the documentation of this file. 36

std::uint32_t

houseRobber

(

const

std::vector<uint32_t> &money,

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... "

;

75

std::cout <<

"passed"

<< std::endl;

79

std::vector<uint32_t> array2 = {6, 7, 1, 3, 8, 2, 4};

80

std::cout <<

"Test 2... "

;

85

std::cout <<

"passed"

<< std::endl;

89

std::vector<uint32_t> array3 = {};

90

std::cout <<

"Test 3... "

;

94

std::cout <<

"passed"

<< std::endl;

98

std::vector<uint32_t> array4 = {2, 7, 9, 3, 1};

99

std::cout <<

"Test 4... "

;

104

std::cout <<

"passed"

<< std::endl;

std::uint32_t houseRobber(const std::vector< uint32_t > &money, const uint32_t &n)

The main function that implements the House Robber algorithm using dynamic programming.

static void test()

Self-test implementations.

int main()

Main function.

Dynamic Programming algorithms.

Functions for the House Robber algorithm.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4