import java.util.Scanner;
class Main
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int t=0;
Main obj=new Main();
t=sc.nextInt();
String in[]=new String[t];
for(int i=0;i<t;i++)
try{ in[i]=sc.next();
}catch(Exception e){}
for(int i=0;i<t;i++)
obj.show(in[i]);
}
public void show(String in)
{
char letter[]=new char[52];
int count[]=new int[52];
int top=0,current=0;
for(int i=0;i<in.length();)
{
int flag=0;
current=0;
while(current<=top)
{
if(in.charAt(i)!=letter[current])
{
current++;
flag=1;
continue;
}
else
{
count[current]++;
flag=0;
break;
}
}
if(flag==1)
{
letter[top]=in.charAt(i);
count[top]++;
top++;
}
i++;
}
int den=1;
for(int i=0;i<top;i++)
den *=fact(count[i]);
System.out.println((fact(in.length())/den)%1000000007);
}
int fact(int n)
{
if(n==1 | n==0)
return 1;
else
return
n*fact(n-1);
}
}
I’m getting NZEC and I can’t figure out the problem
Code runs fine on my PC