Simple CPP Approach

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

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

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


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.


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


okay got it
thanks @rupaladhairya_d9a7fd