标签:
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; }
Leetcode 58 Length of Last Word 难度:0
标签:
原文地址:http://www.cnblogs.com/xuesu/p/4757921.html