国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

LeetCode 58. Length of Last Word

2019-11-08 02:02:28
字體:
來源:轉載
供稿:網友

Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last Word in the string.

If the last word does not exist, return 0.

Note: A word is defined as a character sequence consists of non-space characters only.

For example, Given s = "Hello World",return 5.

程序代碼:

int lengthOfLastWord(char* s) { int count = 0; int i=strlen(s)-1; while(s[i]==' ') i--; while(s[i]!=' '&&i>=0) { count++; i--; } return count;}
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 内江市| 兴安县| 弥渡县| 义乌市| 北宁市| 舒兰市| 麻江县| 古浪县| 上蔡县| 鄢陵县| 宕昌县| 浦北县| 方正县| 右玉县| 廊坊市| 望奎县| 睢宁县| 东至县| 漾濞| 呈贡县| 新闻| 桐城市| 石渠县| 东城区| 鹿邑县| 遵义市| 克什克腾旗| 西城区| 交城县| 光泽县| 峡江县| 宿松县| 潞城市| 梅州市| 叶城县| 武宁县| 武宣县| 昌宁县| 山阳县| 广河县| 遂溪县|