dynamic_programming.max_product_subarray

Functions

max_product_subarray(→ int)

Returns the maximum product that can be obtained by multiplying a

Module Contents

dynamic_programming.max_product_subarray.max_product_subarray(numbers: list[int]) int

Returns the maximum product that can be obtained by multiplying a contiguous subarray of the given integer list nums.

Example: >>> max_product_subarray([2, 3, -2, 4]) 6 >>> max_product_subarray((-2, 0, -1)) 0 >>> max_product_subarray([2, 3, -2, 4, -1]) 48 >>> max_product_subarray([-1]) -1 >>> max_product_subarray([0]) 0 >>> max_product_subarray([]) 0 >>> max_product_subarray(“”) 0 >>> max_product_subarray(None) 0 >>> max_product_subarray([2, 3, -2, 4.5, -1]) Traceback (most recent call last):

ValueError: numbers must be an iterable of integers >>> max_product_subarray(“ABC”) Traceback (most recent call last):

ValueError: numbers must be an iterable of integers