leetcode 434. Number of Segments in a String
来源:互联网 发布:syslog 数据库 编辑:程序博客网 时间:2024/06/05 09:29
原题:
Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters.
Please note that the string does not contain any non-printable characters.
Example:
Input: "Hello, my name is John"Output: 5
代码如下:int countSegments(char* s) {\ if(strlen(s)==0) return 0; int result=0; for(int n=0;n<strlen(s)-1;n++) { if(*(s+n)!=' '&&*(s+n+1)==' ') result++; } if(*(s+strlen(s)-1)!=' ') result++; return result;}这个就是个找特征。。。
阅读全文
0 0
- Leetcode Number of Segments in a String
- LEETCODE--Number of Segments in a String
- LeetCode 434. Number of Segments in a String
- LeetCode 434. Number of Segments in a String
- 【Leetcode 434. Number of Segments in a String】
- leetcode 434. Number of Segments in a String
- LeetCode 434. Number of Segments in a String
- LeetCode 434. Number of Segments in a String
- Leetcode 434. Number of Segments in a String (Easy) (cpp)
- 【LeetCode】 434. Number of Segments in a String
- [leetcode]434. Number of Segments in a String
- [leetcode]434. Number of Segments in a String
- LeetCode 434. Number of Segments in a String
- Leetcode 434. Number of Segments in a String
- Leetcode-434. Number of Segments in a String
- LeetCode-434. Number of Segments in a String
- [LeetCode]434. Number of Segments in a String
- 【Leetcode】434. Number of Segments in a String
- 在中国杀死SAP
- 07next
- ML的常用算法整理
- ehcache配置参数详解
- 用java模拟登录正方教务系统,抓取课表和个人成绩等数据
- leetcode 434. Number of Segments in a String
- 移动 H5 首屏秒开优化方案探讨
- java 对象创建的5种方式
- 多系统引导
- 高逼格利器之Python闭包与装饰器
- 状态模式
- 《Java源码分析》:Vector
- 关于li标签浮动后文字和图片的对齐问题
- VirtualBox共享文件夹设置(主机windows,虚拟机ubuntu)