Update appNew update is available. Click here to update.

Minimum K product

Contributed by
Ashwani
Last Updated: 23 Feb, 2023
Easy
yellow-spark
0/40
Avg time to solve 20 mins
Success Rate 90 %
Share
16 upvotes

Problem Statement

You are given an array 'ARR' of 'N' positive integers and a positive integer 'K'.

Your task is to find the minimum product of K integers of the given array.

Note:

You need to return the product modulo 10^9 + 7.

For Example :

If the given array is [1, 4, 2 ,6, 3] and K = 3. 
Then answer will be 6 by taking the product of integers 1, 2, and 3.

Follow Up:

Can you solve it in less than O(N * logN) time complexity?
Detailed explanation ( Input/output format, Notes, Images )
Sample Input 1 :
1
5 3
5 2 3 8 3
Sample Output 1:
18
Explanation for Input 1:
The minimum product of 3 integers is obtained by choosing (2, 3, 3) which is 18.
Sample Input 2 :
1
6 3
1 2 7 2 3 2
Sample Output 2 :
4
Reset Code
Full screen
Auto
copy-code
Console