Problem with the code?


#1

int Solution::lengthOfLastWord(const string A) {
int len = A.length();
int count = 0;
if(A.length()==0){
return count;
}
int i = len-1;
while(A[i]!=32){
count++;
len–;
}
return count;
}
what is the problem with this code


#2

String with white space at last
Moreover replace len-- with i-- and in while add a condition i>=0