added a new example to check correctness of the code

This commit is contained in:
ABHISHEK-821005 2020-10-31 11:53:40 +05:30 committed by ayaankhan98
parent b2583bb9df
commit e371fc259d

View File

@ -92,6 +92,15 @@ static void test() {
assert(max_profit2 == expected_max_profit2);
std::cout << "Maximum profit with " << n2 << " inch road is " << max_profit2
<< std::endl;
// Test 3
const int16_t n3 = 5; // size of rod
std::array<int32_t, n3> price3 = {2,9,17,23,45}; // price array
const int64_t max_profit3 =
dynamic_programming::cut_rod::maxProfitByCuttingRod(price3, n3);
const int64_t expected_max_profit3 = 45;
assert(max_profit3 == expected_max_profit3);
std::cout << "Maximum profit with " << n3 << " inch road is " << max_profit3
<< std::endl;
}
/**