TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
C++ program for maximum contiguous circular sum problem using Kadane's Algorithm More...
#include <cassert>
#include <iostream>
#include <vector>
Go to the source code of this file.
Namespaces | |
namespace | dynamic_programming |
Dynamic Programming algorithms. | |
Functions | |
int | dynamic_programming::maxCircularSum (std::vector< int > &arr) |
returns the maximum contiguous circular sum of an array | |
static void | test () |
Self-test implementation. | |
int | main (int argc, char *argv[]) |
Main function. | |
C++ program for maximum contiguous circular sum problem using Kadane's Algorithm
The idea is to modify Kadane’s algorithm to find a minimum contiguous subarray sum and the maximum contiguous subarray sum, then check for the maximum value between the max_value and the value left after subtracting min_value from the total sum. For more information, check Geeks For Geeks explanation page.
Definition in file maximum_circular_subarray.cpp.
int main | ( | int | argc, |
char * | argv[] ) |
Main function.
argc | commandline argument count (ignored) |
argv | commandline array of arguments (ignored) |
Definition at line 87 of file maximum_circular_subarray.cpp.
|
static |
Self-test implementation.
Definition at line 64 of file maximum_circular_subarray.cpp.