Write a program to get the number of words possible using an alphabets array.
There could be duplicate alphabets.
Input (Character Array) | Output |
---|---|
{ 'g', 'o', 'o', 'g', 'l', 'e' } | 180 |
{ 'f', 'a', 'c', 'e', 'b', 'o', 'o', 'k' } | 20160 |
{ 's', 'h', 'a', 'r', 'u', 'k', 'k', 'h', 'a', 'n' } | 453600 |
{ 't', 'o', 'l', 'l', 'y', 'w', 'o', 'o', 'd' } | 30240 |
{ 'e', 'n', 'g', 'i', 'n', 'e', 'e', 'r', 'i', 'n', 'g' } | 277200 |
{ 'a', 'a', 'e', 'e', 'e', 'i', 'o', 'o' } | 1680 |
{'a', 'a', 'a'} | 1 |
{}(EMPTY ARRAY) | 1 |
class CobinationsWithDuplicates
{ public static void main(String s[])
{
char array1[] = { 'g', 'o', 'o', 'g', 'l', 'e' };
System.out.println("The Count of combinations with Duplicates are : " + getCombinations(array1));
}
public static int getCombinations(char[] array)
{
//Write a code here to get the number of words possible using an alphabets array and return result.If required, you can use getFactorial method.
}
public static int getFactorial(int number)
{
//Write a code here to get the factorial of a given number and return it.
}
}
Topic: Learn Arrays And Loops