Given an array of n positive integers. We are required to write a program to print the minimum product of k integers of the given array.
Input : 198 76 544 123 154 675 k = 2 Output : 9348 We get minimum product after multiplying 76 and 123. Input : 11 8 5 7 5 100 k = 4 Output : 1400
The idea is simple, we find the smallest k elements and print multiplication of them. In below implementation, we have used simple Heap based approach where we insert array elements into a min heap and then find product of top k elements.
Minimum product is 9348
Time Complexity : O(n * log n)
This article is contributed by Gitanjali Sharma. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Minimum product pair an array of positive Integers
- Longest sequence of positive integers in an array
- Find a pair with maximum product in array of Integers
- Number of arrays of size N whose elements are positive integers and sum is K
- Median in a stream of integers (running integers)
- Program to print N minimum elements from list of integers
- Sum of f(a[i], a[j]) over all pairs in an array of n integers
- Converting an array of integers into Zig-Zag fashion!
- Find the first repeating element in an array of integers
- Check if array contains contiguous integers with duplicates allowed
- Ways to form an array having integers in given range such that total sum is divisible by 2
- Find integers that divides maximum number of elements of the array
- Noble integers in an array (count of greater elements is equal to value)
- Minimum positive integer required to split the array equally
- Print all distinct integers that can be formed by K numbers from a given array of N numbers