58. Length of Last Word

    xiaoxiao2021-03-26  7

    简单得不得简单 不说了

    class Solution { public: int lengthOfLastWord(string s) { int n = s.length(); if(n == 0) return 0; int i; int sum = 0; for(i = n - 1; s[i] == ' ' && i >= 0; -- i); for(;s[i] != ' ' && i >= 0; -- i) sum++; return sum; } };
    转载请注明原文地址: https://ju.6miu.com/read-650202.html

    最新回复(0)