Mr M has recently learned about heaps from geeks for geeks. He started solving problems based on heaps.
However he got stuck on following problem. The problem is as follows:
How many distinct Max Heaps can be made from array of n
integers which satisfies the following constraints :
(n-1)
distinct elements in the array. Or in other words there is exactly one element in the array which is repeated two times.Note: In case of n=2 there will be only 1 distinct element . eg 2 2 .
As answer can be very large output it modulo 109+7.
Please help Mr M solve this problem on Heap. So that he can go ahead can learn new topics.
Input Format
Output Format
Note : Max Heap property is defined as the children nodes must have values less than or equals to the value of their parent.
Test Cases:
Setter : Aayush Kapadia
(1) For first testcase n=3 and the repeated element is the minimum element. So only 1 max heap will be possible which is as follows
(2) For second testcase n=3 and the repeated element is the maximum element. So there will be 2 max heaps possible.