Max Heap is a special kind of complete binary tree in which for every node the value present in that node is greater than the value present in it’s children nodes.
Find the number of distinct Max Heap can be made from A distinct integers.
In short, you have to ensure the following properties for the max heap :
NOTE: If you want to know more about Heaps, please visit this link. Return your answer modulo 109 + 7.
1 <= A <= 100
First and only argument is an integer A.
Return an integer denoting the number of distinct Max Heap.
A = 4
A = 10
Let us take 1, 2, 3, 4 as our 4 distinct integers Following are the 3 possible max heaps from these 4 numbers : 4 4 4 / \ / \ / \ 3 2 , 2 3 and 3 1 / / /
1 1 2
Number of distinct heaps possible with 10 distinct integers = 3360.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.