100: Maximum product of a contiguous subarray

Given an array of integers, return a maximum product in a contiguous subarray

Note: If there is no maximum product, return -1

 

Example 1

Input:   [2, 3, 4]

Output:  24

Example 2

Input:   [-2, -5, - 1, 8]

Output:  40

Explanation: [-5, -1, 8]

Difficulty:Medium
Topic:Dynamic programming
Problem #:100