leetcode 058 Length of Last Word(难易度:Easy)
来源:互联网 发布:广州赐麓网络 编辑:程序博客网 时间:2024/04/25 23:44
Length of Last Word
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) { if(s == NULL || *s == '\0') return 0; int len = strlen(s); int index = len - 1; int lengthoflastword = 0; while(index >= 0 && s[index] == ' ') index --; while (index >= 0 && s[index] != ' ') { lengthoflastword ++; index --; } return lengthoflastword;}原题地址:https://leetcode.com/problems/length-of-last-word/
0 0
- leetcode 058 Length of Last Word(难易度:Easy)
- [Leetcode 58, easy] Length of Last Word
- 【LeetCode】(58)Length of Last Word(Easy)
- <LeetCode><Easy> 58 Length of Last Word
- leetcode 58. Length of Last Word(easy)
- Length of Last Word(easy)
- LeetCode-58-Length of Last Word(字符串)-Easy
- Leetcode 58. Length of Last Word (Easy) (cpp)
- 58.leetcode Length of Last Word(easy)[字符串 分割]
- LeetCode-Easy刷题(12) Length of Last Word
- LeetCode 058 Length of Last Word
- LeetCode 058 Length of Last Word
- LeetCode 058 Length of Last Word
- leetcode 058 Length of Last Word
- LeetCode 058 Length of Last Word
- LeetCode 058 Length of Last Word
- Length of Last Word (leetcode)
- LeetCode(59)Length of Last Word
- CSS中hover改变子元素和其它元素样式
- 系统磁盘IO性能参数解释
- 第三章 数据的图形展示
- zygote oom_score_adj 被设置成1000
- java中判断字符串是否为数字的三种方法
- leetcode 058 Length of Last Word(难易度:Easy)
- java oracle blob字段的内容转成字符窜
- 华为OJ(密码验证合格程序)
- C语言中二进制文件和文本文件的区别
- c++十六进制字符串转数字(数值)
- 网页游戏竞技场功能实现的一种方式
- Oracle XE字符集设置
- Hadoop学习6_CentOS6.5系统下Hadoop2.6.0完全分布式环境安装与配置信息介绍
- 解题报告 之 HDU5326 Work