(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;

    }
}

 

原文地址:https://www.cnblogs.com/codingyangmao/p/11273407.html

时间: 2024-08-30 16:46:38

(Easy) To Lower Case LeetCode的相关文章

LeetCode--To Lower Case &amp; Remove Outermost Parentheses (Easy)

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"

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

这是悦乐书的第301次更新,第320篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第169题(顺位题号是709).实现具有字符串参数str的函数ToLowerCase():以小写形式返回相同的字符串.例如: 输入:"Hello" 输出:"hello" 输入:"here" 输出:"here" 输入:"LOVELY" 输出:"lovely" 本次解题使用的开发工

[LeetCode] To Lower Case 转为小写

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: "L

[LeetCode]709. To Lower Case

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" Examp

(Easy) Diet Plan Performance LeetCode Contest

Description: 5174. Diet Plan Performance My SubmissionsBack to Contest User Accepted:0 User Tried:0 Total Accepted:0 Total Submissions:0 Difficulty:Easy A dieter consumes calories[i] calories on the i-th day.  For every consecutive sequence of k days

709. To Lower Case

Algorithm to-lower-case https://leetcode.com/problems/to-lower-case/ 1)problem Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. Example 1: Input: "Hello" Output: "hello" Exampl

2. To Lower Case

Title: 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" Note: None Analysi

(Easy) Self Dividing Numbers LeetCode

Description: A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0. Also, a self-dividing number is not allowed to contain the

(Easy) Can Make Palindrome - LeetCode Contest (in progress)

Description: Given a string s, we make queries on substrings of s. For each query queries[i] = [left, right, k], we may rearrange the substring s[left], ..., s[right], and then choose up to k of them to replace with any lowercase English letter. If t