Convert Uppercase ASCII Letters

Quick Overview

Convert Uppercase ASCII Letters. Return a copy of s in which each uppercase English letter is replaced by its lowercase counterpart.

Convert Uppercase ASCII Letters

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Other

### Problem Return a copy of s in which each uppercase English letter is replaced by its lowercase counterpart. Leave digits, punctuation, spaces and existing lowercase letters unchanged. ```cpp class Solution { public: string toLowerCase(string s); }; ``` ### Examples **Example 1:** ```text s = "Go-2!" Output: "go-2!" Explanation: Only G changes. ``` **Example 2:** ```text s = "AZ az" Output: "az az" Explanation: The space and lowercase suffix stay unchanged. ``` ### Constraints - The string contains 1 through 100 characters. - Every character is printable ASCII. ### Contract considerations Use the printable ASCII contract, preserving all nonuppercase characters. ```hint Read the boundary condition Which contiguous ASCII interval needs conversion? ``` ### Boundary reminders Use the printable ASCII contract, preserving all nonuppercase characters.

Overview: Convert Uppercase ASCII Letters. Return a copy of s in which each uppercase English letter is replaced by its lowercase counterpart.

Google logo
Google
Source window: 0–3 months · as of Oct 21, 2026
easySoftware EngineerOtherCoding & Algorithms
0
0

Problem

Return a copy of s in which each uppercase English letter is replaced by its lowercase counterpart. Leave digits, punctuation, spaces and existing lowercase letters unchanged.

class Solution {
public:
    string toLowerCase(string s);
};

Examples

Example 1:

s = "Go-2!"
Output: "go-2!"
Explanation: Only G changes.

Example 2:

s = "AZ az"
Output: "az az"
Explanation: The space and lowercase suffix stay unchanged.

Constraints

  • The string contains 1 through 100 characters.
  • Every character is printable ASCII.

Contract considerations

Use the printable ASCII contract, preserving all nonuppercase characters.

Boundary reminders

Use the printable ASCII contract, preserving all nonuppercase characters.