力扣题-11.20
[力扣刷题攻略] Re:从零开始的力扣刷题生活
力扣题1:58. 最后一个单词的长度
解题思想:按空格划分,然后统计单词长度即可

class Solution(object):
    def lengthOfLastWord(self, s):
        """
        :type s: str
        :rtype: int
        """
        word_list = s.split()
        return(len(word_list[-1]))
class Solution {
public:
    int lengthOfLastWord(string s) {
        int result = 0;
        int temp = 0;
        for(int i=0;i<s.size();i++){
            if(s[i]!=' '){
                temp +=1;
            }
            else{
                if(temp!=0){
                    result = temp;
                }
                temp = 0;
            }
        }
        if(temp!=0){
            result = temp;
        }
        return result;
    }
};

















![[跑代码]BK-SDM: A Lightweight, Fast, and Cheap Version of Stable Diffusion](https://img-blog.csdnimg.cn/direct/3b79530f54c44d4bb4d667e299bdfe5b.png)

