45 int max_sum = INT_MIN;
48 max_sum = std::max(max_sum, curr_sum);
49 curr_sum = std::max(curr_sum, 0);
62 std::array<int, N> n{};
64 for (
int i = 0; i < n.size(); i++) {
65 std::cout <<
"Enter value of n[" << i <<
"]"
69 int max_sum = dynamic_programming::kadane::maxSubArray<N>(
71 std::cout <<
"Maximum subarray sum is " << max_sum;
int maxSubArray(const std::array< int, N > &n)
maxSubArray function is used to calculate the maximum sum subarray and returns the value of maximum s...
Dynamic Programming algorithms.
Functions for Kadane algorithm.