题目地址:To Lower Case - LeetCode


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"

大小写转换的题,很简单

Python解法

class Solution:def toLowerCase(self, str: str) -> str:return str.lower()

Java代码如下:

class Solution {public String toLowerCase(String str) {return str.toLowerCase();}
}

函数说明:

public String toLowerCase()
Converts all of the characters in this String to lower case using the rules of the default locale. This is equivalent to calling toLowerCase(Locale.getDefault()).
Note: This method is locale sensitive, and may produce unexpected results if used for strings that are intended to be interpreted locale independently. Examples are programming language identifiers, protocol keys, and HTML tags. For instance, "TITLE".toLowerCase() in a Turkish locale returns "t\u0131tle", where '\u0131' is the LATIN SMALL LETTER DOTLESS I character. To obtain correct results for locale insensitive strings, use toLowerCase(Locale.ENGLISH).Returns:the String, converted to lowercase.
See Also:toLowerCase(Locale)

Java的正规解法:

class Solution {public String toLowerCase(String str) {char[] a = str.toCharArray();for (int i = 0; i < a.length; i++) {if ('A' <= a[i] && a[i] <= 'Z') {a[i] = (char) (a[i] - 'A' + 'a');}}return new String(a);}
}

LeetCode 709 To Lower Case -- java,python解法相关推荐

  1. LeetCode 709:To Lower Case

    C语言: char * toLowerCase(char * str){int a=strlen(str);for(int i=0;i<a;i++){str[i]=tolower(str[i]) ...

  2. Leetcode 709 To Lower Case

    class Solution {public String toLowerCase(String str) {return str.toLowerCase();} }

  3. LeetCode 3. Longest Substring Without Repeating Characters-- c++,java,python解法

    题目地址: Given a string, find the length of the longest substring without repeating characters. Example ...

  4. LeetCode 161. One Edit Distance--Python,Java,C++解法

    题目地址:One Edit Distance - LeetCode 此题链接:One Edit Distance - LeetCode 这道题目进阶版本Edit Distance - LeetCode ...

  5. LeetCode 289. Game of Life--Java,Python解法

    此题链接:Game of Life - LeetCode According to the Wikipedia's article: "The Game of Life, also know ...

  6. LeetCode 1108. Defanging an IP Address--C++,Python解法

    题目地址:Defanging an IP Address - LeetCode Given a valid (IPv4) IP address, return a defanged version o ...

  7. LeetCode 771. Jewels and Stones--Java和Python解法--简单

    题目地址:Jewels and Stones - LeetCode You're given strings J representing the types of stones that are j ...

  8. LeetCode#546. 移除盒子 (Python解法+详细分析)

    问题描述: 给出一些不同颜色的盒子,盒子的颜色由数字表示,即不同的数字表示不同的颜色. 你将经过若干轮操作去去掉盒子,直到所有的盒子都去掉为止.每一轮你可以移除具有相同颜色的连续 k 个盒子(k &g ...

  9. leetcode 5 Longest Palindromic Substring Java JavaScript解法

    题目详情 Given a string s, find the longest palindromic substring in s. You may assume that the maximum ...

最新文章

  1. JAVA 继承基本类、抽象类、接口
  2. 《COM组件开发实践》系列文章
  3. Git学习笔记03--git reset
  4. 企业级分布式事务设计实践解决方案
  5. C语言左移位符号 << 结合 |= 实现置位操作
  6. iostat来对linux硬盘IO性能进行了解
  7. iscsi:IO操作流程(四)
  8. 如何编写完美的 Python 命令行程序?
  9. ffmpeg编码视频总结
  10. 射频前端行业信息汇总
  11. 地理信息安全在线培训考试系统题库-单选题
  12. Linux内核五个安全模块简述
  13. 等比 / 等差数列求和公式
  14. 日志:实现微信公众号自动问答机器人(待整理)
  15. 七种方法绕过安卓手机锁屏
  16. i5 6600 HD530联想扬天S5250黑苹果
  17. 人体姿态2018(五)Can 3D Pose be Learned from 2D Projections Alone?
  18. oracle按照姓名查询,Oracle 10g如何对用户姓名,按首字母排序、查询
  19. 天龙八部元宝兑换代码
  20. DRF框架及APIView

热门文章

  1. CLASSPATH的作用
  2. DNA提取方法对浮游生物群落研究结果的影响
  3. MPB:张云增、王年等-​柑橘根际和根表微生物组样品的收集及核酸提取方法
  4. 为什么越来越多硕博人消失在朋友圈?
  5. Nature:梁冠翔等发现肠道病毒组在新生儿体内分段寄生的模式
  6. QIIME 2教程. 20实用程序Utilities(2020.11)
  7. 微生物绝对定量or相对定量,你选对了吗
  8. 插拔式java_# 可插拔式组件设计,领略组件开发的奥秘
  9. echart饼状图没有数据的时候显示暂无数据_Python数据结构可视化 day 5
  10. pandas索引复合索引dataframe数据、索引其中一个水平(level)的特定数据列(index a column of a level)