Convert String to LowerCase | Practice | GeeksforGeeks

Given a string S. The task is to convert characters of string to lowercase.
Example 1:
Input: S = "ABCddE"
Output: "abcdde"
Explanation: A, B, C and E are converted to
a, b, c and E thus all uppercase characters 
of the string converted to lowercase letter.
Example 2:
Input: S = "LMNOppQQ"
Output: "lmnoppqq"
Explanation: L, M, N, O, and Q are 
converted to l, m, n, o and q thus 
all uppercase characters of the 
string converted to lowercase letter.
Your Task:  
You dont need to read input or print anything. Complete the function toLower() which takes S as input parameter and returns the converted string.
Expected Time Complexity:O(n)
Expected Auxiliary Space: O(1) 
Constraints:
1 <= |S| <= 1000
0
rohitjaroli226 hours ago
class Solution {   static String toLower(String S) {       String str="";      str=S.toLowerCase();      return str;   }}
0
bpanchal758 hours ago
class Solution {   static String toLower(String S) {       String s = S.toLowerCase();       return s;   }}
0
dwcahtyin16 hours ago
CPP
class Solution { public:   string toLower(string S) {       // code here       for(auto& s : S){           s = tolower(s);       }       return S;   }};
0
sojwal2 days ago
//JAVA
 
class Solution {
    static String toLower(String S) {
        // code here
        
        char [] a = S.toCharArray();
        
        for(int i = 0; i < a.length; i++){
            if(a[i] <91 && a[i] > 64 ){
                a[i] = (char)((int) a[i] + 32);
            }
        }
        
        return String.valueOf(a);
    }
}
0
balagopen82x66 days ago
WITHOUT USING ANY PREDEFINED FUNCTON 
class Solution {   static String toLower(String S) {             char [] a= S.toCharArray();   int n= a.length;       for(int i=0;i<n;i++)       {           if(a[i]>='A' && a[i]<='Z')           {               a[i]=(char)((int)a[i]+32);           }       }  String s=String.valueOf(a);       return s;
}
+1
smartankit19981 week ago
Simple Code in JavascripttoLower(arr,n){       //code here       return arr.toLowerCase()   }
0
yogeshbisht2122 weeks ago
//1st method
 
string toLower(string S) {       for(int i=0;i<S.size();i++)       {           if(S[i]>='A' && S[i]<='Z')           {               S[i]+=32;           }       }       cout<<S;// code here   }
 
//2nd method
 
transform(S.begin(),S.end(),S.begin(),::tolower);
+1
amkamble222 weeks ago
Simple code in java.....
 
class Solution {   static String toLower(String S) {       // code here       return S.toLowerCase();   }}
 
 
0
brmdinhata2 weeks ago
class Solution { public:   string toLower(string S) {       transform(S.begin(),S.end(),S.begin(),::tolower);       // code here       return S;   }};
0
sakshinagdive153 weeks ago
For Python3
 
class Solution:   def toLower (ob, S):        return S.lower()
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested 
                                    against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code.
                                    On submission, your code is tested against multiple test cases consisting of all
                                        possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as
                                        the final solution code.
You can view the solutions submitted by other users from the submission tab.
Make sure you are not using ad-blockers.
Disable browser extensions.
We recommend using latest version of your browser for best experience.
Avoid using static/global variables in coding problems as your code is tested 
                                against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases in coding problems does not guarantee the 
                                correctness of code. On submission, your code is tested against multiple test cases
                                    consisting of all possible corner cases and stress constraints.