Template Class max_subarray_finder

Class Documentation

template<typename T>
class max_subarray_finder

Find the maximal subarray using Kadane’s algorithm, which is O(n).

Public Functions

inline boost::optional<std::tuple<T, int, int>> operator()(const std::vector<T> &arr) const

Find the maximal subarray from the source array.

Returns:

(sum, start index (inclusive), end index (inclusive)), if one is found.