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/db/dfb/maximum__circular__subarray_8cpp.html below:

TheAlgorithms/C++: dynamic_programming/maximum_circular_subarray.cpp File Reference

Loading...

Searching...

No Matches

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.

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.

◆ main()

Main function.

Returns
0 on exit

Definition at line 84 of file maximum_circular_subarray.cpp.

84 {

86 return 0;

87}

static void test()

Self-test implementation.

◆ test()

Self-test implementation.

Returns
void

Definition at line 64 of file maximum_circular_subarray.cpp.

64 {

65

66

67

68

69

70 std::vector<int> arr = {8, -8, 9, -9, 10, -11, 12};

72

73 arr = {8, -8, 10, -9, 10, -11, 12};

75

76 std::cout << "All tests have successfully passed!\n";

77}

int maxCircularSum(std::vector< int > &arr)

returns the maximum contiguous circular sum of an array


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