LeetCode 709 To Lower Case 解题报告
题目要求
Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.
题目分析及思路
题目要求返回一个字符串的小写形式。可以直接使用lower()函数。如果考虑具体的实现逻辑,则将大写字符转成小写字符即可,判断字符是否处在‘A’~‘Z’之间,如果是的话,就把它转成小写字符。
python代码
class Solution:
def toLowerCase(self, str):
"""
:type str: str
:rtype: str
"""
res = ""
for s in str:
if ord(s)>=ord('A') and ord(s)<=ord('Z'):
res += chr(ord(s)-ord('A')+ord('a'))
else:
res += s
return res
LeetCode 709 To Lower Case 解题报告的更多相关文章
- 【LeetCode】709. To Lower Case 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述: 题目大意 解题方法 ASIIC码操作 日期 题目地址:https:// ...
- Leetcode#709. To Lower Case(转换成小写字母)
题目描述 实现函数 ToLowerCase(),该函数接收一个字符串参数 str,并将该字符串中的大写字母转换成小写字母,之后返回新的字符串. 示例 1: 输入: "Hello" ...
- LeetCode 709.To Lower Case
Description Implement function ToLowerCase() that has a string parameter str, and returns the same s ...
- LeetCode 709. To Lower Case (转换成小写字母)
题目标签:String 题目让我们把大写字母转换成小写,只要遇到的是大写字母,把它 + 32 变成 小写就可以了. Java Solution: Runtime beats 100.00% 完成日期: ...
- 【LeetCode】375. Guess Number Higher or Lower II 解题报告(Python)
[LeetCode]375. Guess Number Higher or Lower II 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://f ...
- 709. To Lower Case - LeetCode
Question 709. To Lower Case Sollution 题目大意:字符串大写转小写 思路: 直接调用Java API函数 字符串转char数组,遍历数组,判断如果大写就转小写 Ja ...
- 【LeetCode】392. Is Subsequence 解题报告(Python)
[LeetCode]392. Is Subsequence 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/is-subseq ...
- 【LeetCode】911. Online Election 解题报告(Python)
[LeetCode]911. Online Election 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ ...
- 【LeetCode】722. Remove Comments 解题报告(Python)
[LeetCode]722. Remove Comments 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/remove-c ...
随机推荐
- Android 实时录音和回放,边录音边播放 (KTV回音效果)
上一篇介绍了如何使用Mediarecorder来录音,以及播放录音.不过并没有达到我的目的,一边录音一边播放.今天就讲解一下如何一边录音一边播放.使用AndioRecord录音和使用AudioTrac ...
- 使用Profile和Resources Filter隔离测试环境
转自:http://juvenshun.iteye.com/blog/206825 Maven能够帮我们很好的管理测试,我们可以在 src/test/java 和 src/test/resources ...
- Generate class from database table How can i generate a class from a table at a SQL Server?
Set @TableName to the name of your table. declare @TableName sysname = 'TableName' declare @Result v ...
- 网络编程 -- RPC实现原理 -- RPC -- 迭代版本V2 -- 本地方法调用 整合 Spring
网络编程 -- RPC实现原理 -- 目录 啦啦啦 V2——RPC -- 本地方法调用 + Spring 1. 配置applicationContext.xml文件 注入 bean 及 管理 bean ...
- VS Release模式调试
c++ -> 常规 -〉调试信息格式 选 程序数据库(/Zi)或(/ZI) c++ -> 优化 -〉优化 选 禁止(/Od) 连接器 -〉调试 -〉生成调试信息 选 是 (/DEBUG)
- Unity Shader 景深效果
效果 原理: 开启摄像机的深度模式,将深度保存到一张名为_CameraDepthTexture(Unity5.0之后才有)内置的纹理中. 如果深度在焦点范围内就用原图,否则就用模糊图. Shader: ...
- G - Line of Sight
来源poj2074 An architect is very proud of his new home and wants to be sure it can be seen by people p ...
- 可访问性(Accessibility) => 无障碍功能
了解无障碍功能及其范围和影响可令您成为更出色的网络开发者 复杂的一笔 https://developers.google.cn/web/fundamentals/accessibility/ ARIA ...
- VBS数组导出到Excel
<script language="vbscript"> dim arr(9999,4) for i=0 to 9999 for j = 0 to 4 arr(i,j) ...
- (广度搜索)A - Prime Path(11.1.1)
A - Prime Path(11.1.1) Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64 ...