본문 바로가기
Problem Solving/LeetCode

[LeetCode] 709. To Lower Case - Java

by graycode 2026. 10. 2.

• 문제 링크

 

To Lower Case - LeetCode

Can you solve this real interview question? To Lower Case - Given a string s, return the string after replacing every uppercase letter with the same lowercase letter.   Example 1: Input: s = "Hello" Output: "hello" Example 2: Input: s = "here" Output: "he

leetcode.com

 

• 풀이 코드

public class Solution {

    public String toLowerCase(String s) {
        char[] arr = s.toCharArray();
        for (int i = 0; i < arr.length; i++) if (arr[i] > 64 && arr[i] < 91) arr[i] |= 32;

        return new String(arr);
    }

}

댓글