博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[LeetCode] 434. Number of Segments in a String_Easy
阅读量:4696 次
发布时间:2019-06-09

本文共 383 字,大约阅读时间需要 1 分钟。

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 Code
class Solution:    def countSegments(self, s):        return len(s.split())

 

转载于:https://www.cnblogs.com/Johnsonxiong/p/9545673.html

你可能感兴趣的文章
在UTF-8中,一个汉字为什么需要三个字节?
查看>>
学习ThreadLocal
查看>>
在 Visual Studio 调试器中指定符号 (.pdb) 和源文件
查看>>
直接量
查看>>
leetcode 115. 不同的子序列(Distinct Subsequences)
查看>>
三元表达式
查看>>
Go初接触之libjpeg-turbo
查看>>
UVa 11300 Spreading the Wealth 分金币
查看>>
[leetcode] Happy Number
查看>>
Java第五周学习总结
查看>>
j.c.Warnsdorff马踏棋盘算法
查看>>
the openning
查看>>
python 字符串 和 print
查看>>
MAC OS下安装Minizip
查看>>
Java_Certificates does not conform to algorithm constraints
查看>>
PAT 1027. Colors in Mars
查看>>
linux定时执行脚本
查看>>
Oauth支持的5类 grant_type 及说明
查看>>
ASP.NET 5 DNX SDK删除旧版本
查看>>
Android ListView 九大重要属性详细分析
查看>>