# Python Example – Write a Python program to compute maximum product of three numbers of a given array of integers using Heap queue algorithm # (Python Example for Citizen Data Scientist & Business Analyst)

Write a Python program to compute maximum product of three numbers of a given array of integers using Heap queue algorithm.

Sample Solution:

Python Code:

``````
def maximumProduct(nums):
import heapq
a, b = heapq.nlargest(3, nums), heapq.nsmallest(2, nums)
return max(a * a * a, a * b * b)

arr_nums = [12, 74, 9, 50, 61, 41]

print("Original array elements:")
print(arr_nums)
print("Maximum product of three numbers of the said array:")
print(maximumProduct(arr_nums))
``````

Sample Output:

```Original array elements:
[12, 74, 9, 50, 61, 41]
Maximum product of three numbers of the said array:
225700```

## Write a Python program to compute maximum product of three numbers of a given array of integers using Heap queue algorithm

#### Free Machine Learning & Data Science Coding Tutorials in Python & R for Beginners. Subscribe @ Western Australian Center for Applied Machine Learning & Data Science. ```