Why this code get TLE


#1

#define mod 1000000007
int Solution::solve(int A, int B) {
if(A>B) return 0;
else
{
long int result=1;
while(A–)
{
result=(result*B)%mod;
B–;
}
return (int)result%mod;
}


#2

Managed to pass 100% of tests with java version of this, almost verbatim.