【LeetCode】Length of Last Word 解题报告
来源:互联网 发布:三菱触摸屏编程软件 编辑:程序博客网 时间:2024/06/06 01:27
【LeetCode】Length of Last Word 解题报告
标签(空格分隔): LeetCode
题目地址:https://leetcode.com/problems/length-of-last-word/description/
题目描述:
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.
Examle:
input:
"Hello World""Hello World ""Hello W orld""Hello Wo rld"
output:
5543
Ways
使用库函数,方法比较简单,一行代码。
class Solution(object): def lengthOfLastWord(self, s): """ :type s: str :rtype: int """ return len(s.strip().split(' ')[-1])
Date
2017 年 8 月 24 日
阅读全文
0 0
- [Leetcode] Length of Last Word 解题报告
- 【LeetCode】Length of Last Word 解题报告
- [leetcode] 58. Length of Last Word 解题报告
- [Leetcode] 58. Length of Last Word 解题报告
- [LeetCode 解题报告]058. Length of Last Word
- Leetcode #58. Length of Last Word 末尾词长 解题报告
- leetcode解题之58 # Length of Last Word Java版
- leetcode解题方案--058--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
- 动态规划之01背包,完全背包,多重背包模板
- RXJava入门01
- 导航栏翻转效果
- 加载本地pdf文件,关于so文件的坑
- 时间戳转为C#格式时间 (互转)
- 【LeetCode】Length of Last Word 解题报告
- Splay模板
- 初识html
- hdu 6156
- RCC相关头文件和固件库源文件
- Android 屏幕适配方案
- sizeof 关键字总结
- 3种web会话管理的方式
- Spark为何使用Netty通信框架替代Akka