(Easy) To Lower Case LeetCode

Posted codingyangmao

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了(Easy) To Lower Case LeetCode相关的知识,希望对你有一定的参考价值。

Description

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"

Solution

class Solution 
    public String toLowerCase(String str) 
        String output = "";
        
        for(int i = 0; i< str.length(); i++)
            
            if((int)str.charAt(i)>=65 && (int)str.charAt(i)<=90)
                
                output = output+ (char)(str.charAt(i)+32);
                
            
            
            else
                
                output = output+str.charAt(i);
            
        
        
        return output;
        
    

技术图片

 

 

以上是关于(Easy) To Lower Case LeetCode的主要内容,如果未能解决你的问题,请参考以下文章

LeetCode算法题-To Lower Case(Java实现)

0709-To Lower Case(转换成小写字母)

0709-To Lower Case(转换成小写字母)

0709-To Lower Case(转换成小写字母)

Leet Code OJ 8. String to Integer (atoi) [Difficulty: Easy]

Leet Code OJ 58. Length of Last Word [Difficulty: Easy]