To Lower Case Problem


Description

LeetCode Problem 709.

Given a string s, return the string after replacing every uppercase letter with the same lowercase letter.

Example 1:

1
2
Input: s = "Hello"
Output: "hello"

Example 2:

1
2
Input: s = "here"
Output: "here"

Example 3:

1
2
Input: s = "LOVELY"
Output: "lovely"

Constraints:

  • 1 <= s.length <= 100
  • s consists of printable ASCII characters.


Sample C++ Code

1
2
3
4
5
6
7
8
9
class Solution {
public:
    string toLowerCase(string str) {        
        for (char& c : str) {
            if (c >= 'A' && c <= 'Z') c += 32;
        }
        return str;
    }
};




Related Posts

String Without Aaa Or Bbb Problem

LeetCode 984. Given two integers a and b, return any...

Shifting Letters Problem

LeetCode 848. You are given a string s of lowercase...

Positions Of Large Groups Problem

LeetCode 830. In a string sof lowercase letters, these letters...

Orderly Queue Problem

LeetCode 899. You are given a string s and an...

Number Of Lines To Write String Problem

LeetCode 806. You are given a string s of lowercase...

Masking Personal Information Problem

LeetCode 831. You are given a personal information string s,...