leetcode 434[easy]---Number of Segments in a String
来源:互联网 发布:男生护肤品知乎 编辑:程序博客网 时间:2024/05/20 04:50
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
Seen this question in a real interview before? No
Thanks for your feedback.
思路:用s.split()以空格键分割string,并以list形式输出
阅读全文