【Leetcode】【python】Length of Last Word
来源:互联网 发布:java unix时间戳 时区 编辑:程序博客网 时间:2024/06/04 17:56
题目大意
找出最后一个单词的长度。
注意点:
忽略尾部空格
不存在最后一个单词时返回0
解题思路
简单题,其实题目假设了不会出现数字字符等,不然这样做是过不了的。还需要判断是否这个word全为65 <= ord() <= 122
代码
class Solution(object): def lengthOfLastWord(self, s): """ :type s: str :rtype: int """ return len(s.strip().split(" ")[-1])
总结
阅读全文
0 0
- 【LeetCode with Python】 Length of Last Word
- LeetCode--Length of Last Word (Python)
- 58. Length of Last Word Leetcode Python
- [leetcode:python]58.Length of Last Word
- 【Leetcode】【python】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
- [leetcode] Length of Last Word
- leetcode length of last word
- LeetCode - Length of Last Word
- 【Go】包
- LIstview原理
- 谈谈 CGI、FastCGI、PHP-CGI、PHP-fpm
- nginx 的 php 开发环境部署
- Python第三方库安装笔记
- 【Leetcode】【python】Length of Last Word
- QQ邮箱SMTP发送源码及jar包
- JDATA 腾讯广告赛
- ThinkPHP5.0集成七牛云--对象存储服务
- Decision Tree
- 洛谷日记8
- 开发者山行图,找到你的收入和位置
- 创建自己的搜索引擎,利用google进行站内搜索
- Android Studio上进行NDK编程之Hello world