Length of Last Word

2018/1/18 posted in  leetcode
![](media/15162389890253/15162389958774.jpg)
class Solution {
public:
    int lengthOfLastWord(string s) {
        int len = s.size();
        int cout = 0;
        for (int i=len-1; i>=0; i--) {
            if(cout>0&&s[i]==' ') break;

            if (s[i]==' ') {
                continue;
            }else{
                cout++;
            }

        }
        return cout;
    }
};