My python solution( taking care of all corner cases)


#1

if(len(str©)<B):
return(0)

    if(B==1):
        count0=0
        for i in A:
            if(i<C):
                count0+=1
        return(count0)
    
        
    if(len(str(C))>B):
        if 0 in A:
            return((len(A)**B)-(len(A)**(B-1)))
        else:
            return(len(A)**B)
        
    if(len(str(C))==B):
        strC=str(C)
        count=0
        for k in range(len(A)):
            if(A[k]<int(strC[0])):
                count+=1
            if(A[k]==0 and B>1):
                count-=1

        result=count*(len(A)**(B-1))
        if(int(strC[0]) in A):
            i=1
            while(i<B):
                count1=0
                m=B-(i+1)
                if(m>=0):
                    for j in range(len(A)):
                        if(A[j]<int(strC[i])):
                            count1+=1
                    result+=count1*(len(A)**m)
                    if(int(strC[i]) in A):
                        i+=1
                    else:
                        break
        return(result)