other.maximum_subsequence

Attributes

n

Functions

max_subsequence_sum(→ int)

Return the maximum possible sum amongst all non - empty subsequences.

Module Contents

other.maximum_subsequence.max_subsequence_sum(nums: collections.abc.Sequence[int] | None = None) int

Return the maximum possible sum amongst all non - empty subsequences.

Raises:

ValueError: when nums is empty.

>>> max_subsequence_sum([1,2,3,4,-2])
10
>>> max_subsequence_sum([-2, -3, -1, -4, -6])
-1
>>> max_subsequence_sum([])
Traceback (most recent call last):
    . . .
ValueError: Input sequence should not be empty
>>> max_subsequence_sum()
Traceback (most recent call last):
    . . .
ValueError: Input sequence should not be empty
other.maximum_subsequence.n