i start iterating from i=1; so if A=; it should not enter the loop at all; and it should go directly to the return statement and return 0. instead there’s something weird going on;
for A =  length is still 1. So instead of 0 you should return 1.
Make your code return 1 for A and it will be correct. InterviewBit’s output thats shown is wrong .