Maximum Product from List of Integers in Python
The challenge
Given an array of integers, Find the maximum product obtained from multiplying 2 adjacent numbers in the array.
Notes
- Array/list size is at least 2.
- Array/list numbers could be a mixture of positives, negatives also zeroes .
Input >Output Examples
|
|
Explanation:
The maximum product is obtained from multiplying 2 * 3 = 6
, and they’re adjacent numbers in the array.
|
|
Explanation:
Max product obtained from multiplying 5 * 10 = 50
.
|
|
Explanation:
The maximum product obtained from multiplying -2 * 7 = -14
, and they’re adjacent numbers in the array.
The solution in Python code
Option 1:
Option 2:
Option 3:
Test cases to validate our solution
|
|