https://www.geeksforgeeks.org/count-subsequences-maximum-distinct-elements/
Given an arr of size n. The problem is to count all the subsequences having maximum number of distinct elements.
Examples:
Input : arr[] = {4, 7, 6, 7} Output : 2 The indexes for the subsequences are: {0, 1, 2} - Subsequence is {4, 7, 6} and {0, 2, 3} - Subsequence is {4, 6, 7}
Efficient Approach: Create a hash table to store the frequency of each element of the array. Take product of all the frequencies.
The solution is based on the fact that there is always 1 subsequence possible when all elements are distinct. If elements repeat, every occurrence of repeating element makes a mew subsequence of distinct elements
The solution is based on the fact that there is always 1 subsequence possible when all elements are distinct. If elements repeat, every occurrence of repeating element makes a mew subsequence of distinct elements