TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Implementation of House Robber Problem algorithm. More...
#include <cassert>
#include <climits>
#include <cstdint>
#include <iostream>
#include <vector>
Go to the source code of this file.
Namespaces | |
namespace | dynamic_programming |
Dynamic Programming algorithms. | |
namespace | house_robber |
Functions for the House Robber algorithm. | |
Functions | |
std::uint32_t | dynamic_programming::house_robber::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. | |
Implementation of House Robber Problem algorithm.
Solution of House robber problem uses a dynamic programming concept that works in \(O(n)\) time and works in \(O(1)\) space.
Definition in file house_robber.cpp.
std::uint32_t dynamic_programming::house_robber::houseRobber | ( | const std::vector< uint32_t > & | money, |
const uint32_t & | n ) |
The main function that implements the House Robber algorithm using dynamic programming.
money | array containing money in the ith house |
n | size of array |
Definition at line 36 of file house_robber.cpp.
int main | ( | void | ) |
Main function.
Definition at line 111 of file house_robber.cpp.
|
static |
Self-test implementations.
Definition at line 66 of file house_robber.cpp.