Skip to content

709_ToLowerCase

a920604a edited this page Apr 14, 2023 · 1 revision

title: 709. To Lower Case categories: leetcode comments: false

solution

class Solution {
public:
    string toLowerCase(string s) {
        string str;
        for(char c: s){
            if(c>='A' && c<='Z') c+=32;
            str+=c;
        }
        return str;
    }
};

analysis

  • time complexity O(n)
  • space complexity O(1)
Clone this wiki locally