Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6379 |

@blackshadows | 6329 |

@mb1973 | 5358 |

@Quandray | 5231 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4510 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3357 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@ritiksethi21 | 1050 |

@aroranayan999 | 807 |

@RizulBansal | 685 |

@ashishtrehan002 | 538 |

@hemantgarg923 | 528 |

@simrangoyal | 526 |

@ronaldo77 | 520 |

@anishrajan | 505 |

@thanosagain | 505 |

@ssparteek470 | 495 |

@rahul2312 | 491 |

Complete Leaderboard |

Let Max be the maximum possible mean of a multiset of values obtained from an array **Arr **of length **N**. Let Min be the minimum possible mean of a multiset of values obtained from the same array. Note that in a multiset values may repeat. The task is to find the **number of multisets** with mean as Max and the number of multisets with mean as Min. The answer may be too large so output the number of multisets modulo 10^{9}+7.

**Example 1:**

Input:N =5Arr ={3, 1, 2, 3, 4}Output:1 1Explanation:The maximum possible Mean of a Subset of the array is 4. There can be only 1 such subset - {3, 1, 2, 3,4}. The minimum possible Mean of a Subset of the array is 1. There can be only 1 such subset - {3,1, 2, 3, 4}.

**Example 2:**

Input:N =3Arr ={1, 2, 1}Output:1 3Explanation:The maximum possible Mean of a Subset of the array is 2. There can be only 1 such subset - {1,2, 1}. The minimum possible Mean of a Subset of the array is 1. There can be 3 such subsets - {1, 2, 1}; {1, 2,1}; {1, 2,1}.

**Your Task:**

You don't need to read input or print anything. Your task is to complete the function **numOfSubsets()** which takes an Integer N and an array Arr[] as input and returns a vector of two numbers- the number of multisets with mean as Max and the number of multisets with mean as Min.

**Expected Time Complexity:** O(N)

**Expected Auxiliary Space:** O(N)

**Constraints:**

1 <= N <= 10^{5}

1 <= Arr[i] <= 10^{5}

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Number of subsets and mean

...