[LeetCode] 709. To Lower Case_Easy
Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.
Example 1:
Input: "Hello"
Output: "hello"
Example 2:
Input: "here"
Output: "here"
Example 3:
Input: "LOVELY"
Output: "lovely" Code
class Solution:
def toLower(self, s):
ans = ""
for c in s:
if ord('A') <= ord(c) <= ord('Z'):
ans += chr(ord('a') + ord(c) - ord('A'))
else:
ans += c
return ans
[LeetCode] 709. To Lower Case_Easy的更多相关文章
- Leetcode#709. To Lower Case(转换成小写字母)
题目描述 实现函数 ToLowerCase(),该函数接收一个字符串参数 str,并将该字符串中的大写字母转换成小写字母,之后返回新的字符串. 示例 1: 输入: "Hello" ...
- LeetCode 709 To Lower Case 解题报告
题目要求 Implement function ToLowerCase() that has a string parameter str, and returns the same string i ...
- LeetCode 709. To Lower Case (转换成小写字母)
题目标签:String 题目让我们把大写字母转换成小写,只要遇到的是大写字母,把它 + 32 变成 小写就可以了. Java Solution: Runtime beats 100.00% 完成日期: ...
- LeetCode 709.To Lower Case
Description Implement function ToLowerCase() that has a string parameter str, and returns the same s ...
- 709. To Lower Case - LeetCode
Question 709. To Lower Case Sollution 题目大意:字符串大写转小写 思路: 直接调用Java API函数 字符串转char数组,遍历数组,判断如果大写就转小写 Ja ...
- 【Leetcode_easy】709. To Lower Case
problem 709. To Lower Case solution1: class Solution { public: string toLowerCase(string str) { stri ...
- 【LeetCode】709. To Lower Case 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述: 题目大意 解题方法 ASIIC码操作 日期 题目地址:https:// ...
- 【Leetcode】709. To Lower Case
To Lower Case Description Implement function ToLowerCase() that has a string parameter str, and retu ...
- 【LeetCode】To Lower Case(转换成小写字母)
这道题是LeetCode里的第709道题. 题目要求: 实现函数 ToLowerCase(),该函数接收一个字符串参数 str,并将该字符串中的大写字母转换成小写字母,之后返回新的字符串. 示例 1: ...
随机推荐
- hadoop Codec
- Mapper 赋值对应实体属性
public static class MapperExtensions { public static TResult MapTo<TResult>(this object self, ...
- RMQ算法详解
RMQ算法,是一个快速求区间最值的离线算法,预处理时间复杂度O(n*log(n)),查询O(1),所以是一个很快速的算法. 当然这个问题用线段树同样能够解决,算法复杂度为:O(N)~O(logN) . ...
- 内存不够怎么办? 1.5.1 关于隔离 1.5.2 分段(Segmention) 1.5.3 分页(Paging)
小结: 1. 内存不够怎么办?1.5.1 关于隔离1.5.2 分段(Segmention)1.5.3 分页(Paging) <程序员的自我修养——链接.装载与库>
- #include<stdio.h> #include "stdio.h"
https://baike.baidu.com/item/#include <stdio.h> #include <stdio.h> 编辑 #include<stdio. ...
- ios -RunLoop(简单理解)
一. RunLoop简介 RunLoop字面意思是运行时,即跑圈得意思.它可以在我们需要的时候自己跑起来运行,在我们没有操作的时候就停下来休息,充分节省CPU资源,提高程序性能. 二. RunLoop ...
- [bigdata] palantir
Palantir的无缝数据融合技术关键在于本体数据模型的灵活性,动态性,而且要能反映人.事.物和环境的关联关系及因果联系,这是大数据技术面临的核心挑战.
- [knowledge][dpdk] open data plane
https://www.opendataplane.org/ https://en.wikipedia.org/wiki/OpenDataPlane odp vs dpdk: http://dpdk ...
- [apr] Apache Portable Runtime
接手新项目,前任大量的使用了APR,虽然不影响理解主逻辑,但是看见一行不知道干嘛的代码,总是特别炸眼. 况且,虽然我从来不跨平台.但是APR如此优秀,学习理解它都不是浪费时间. 可是让人崩溃的是,竟然 ...
- LeetCode 917 Reverse Only Letters 解题报告
题目要求 Given a string S, return the "reversed" string where all characters that are not a le ...