leetcode Length of Last Word
来源:互联网 发布:软件开发 证书 编辑:程序博客网 时间:2024/05/29 09:38
题目:https://oj.leetcode.com/problems/length-of-last-word/
题意:统计最后一个单词的字母个数
思路:注意开始和结尾的空格就行
class Solution {public: int lengthOfLastWord(const char *s) { int len = strlen(s); if(len == 0) return 0; int count = 0; while(s[--len] == ' '); while(len>=0){ if(s[len] == ' ') break; count ++; len--; } return count; }};
0 0
- LeetCode: Length of Last Word
- LeetCode Length of Last Word
- LeetCode : Length of Last Word
- [Leetcode] Length of Last Word
- [LeetCode] Length of Last Word
- [LeetCode]Length of Last Word
- [leetcode]Length of Last Word
- Leetcode:Length of Last Word
- LeetCode-Length of Last Word
- [LeetCode] Length of Last Word
- [leetcode] Length of Last Word
- leetcode length of last word
- LeetCode - Length of Last Word
- leetcode:Length of Last Word
- LeetCode:Length of Last Word
- LeetCode | Length of Last Word
- LeetCode - Length of Last Word
- Leetcode: Length of Last Word
- Java基础(面向对象一——理解、匿名函数、封装、构造函数和this关键字的使用)
- 巴菲特致股东的一封信:2000年
- Add All - UVa 10954 优先队列
- 7 飞机(背景)移动图
- Unity中的快捷键(整理)
- leetcode Length of Last Word
- 数据本地存储的文件夹及其路径
- oc的字典(课件整理)
- Copying Books - UVa 714 dp
- OC学习里面的一些概念(一)
- 7 全屏 小球下落
- iOS8.1.3下Inhouse App无法安装问题
- 【BZOJ 2326】 [HNOI2011]数学作业
- 省市