Leetcode 58 Length of Last Word 难度:0
https://leetcode.com/problems/length-of-last-word/
int lengthOfLastWord(char* s) {
    int ans = 0;
    int fans = 0;
    for(int i = 0;s[i];i++){
        if (s[i] ==' '){fans = ans;ans = 0;while(s[i + 1] == ' '){i++;}}
        else ans++;
    }
    return ans?ans:fans;
}
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号