Simple CPP Approach


#1
int cnt=0;
int i=A.size()-1;

while(A[i]==' ' && i>=0)
    i--;

while(i>=0 && A[i]!=' ')
{
    cnt++;
    i--;
}
return cnt;

#2

while(A[i]==ā€™ ā€™ &&i>=0) iā€“;
hello rupal can you plz tell me the use of the above piece of code
bz without this code my programme is running on my local compiler and its giving me the right answer.


#3

Ok @manvi-sharma1 here in the last word we only have to consider the alphabetical string, so I am just skipping the whitespace at the end. I Hope it will help you


#4

okay got it
thanks @rupaladhairya_d9a7fd