[코테 풀이] To Lower Case

시내·2024년 6월 7일

Q_709) To Lower Case

출처 : https://leetcode.com/problems/to-lower-case/?envType=study-plan-v2&envId=programming-skills

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

class Solution {
    public String toLowerCase(String s) {
        String res = "";
        for (int i = 0; i < s.length(); i++) {
            if (Character.isUpperCase(s.charAt(i))) {
                res += Character.toLowerCase(s.charAt(i));
            } else {
                res += s.charAt(i);
            }
        }
        return res;
    }
}
profile
contact 📨 ksw08215@gmail.com

0개의 댓글