-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlec7_toLower.cpp
51 lines (41 loc) Β· 971 Bytes
/
lec7_toLower.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// https://www.geeksforgeeks.org/problems/java-convert-string-to-lowercase2313/1?utm_source=geeksforgeeks&utm_medium=ml_article_practice_tab&utm_campaign=article_practice_tab
//seg fault 1010/1012 test cases
//{ Driver Code Starts
// Initial Template for C++
#include <bits/stdc++.h>
using namespace std;
// } Driver Code Ends
// User function Template for C++
class Solution {
void to_lower(string &S , int index)
{
if (index < 0 || index >= S.length()) {
return;
}
if( S[index] >='A' &&S[index]<='Z')
{
S[index] = S[index]-'A' +'a';
}
to_lower(S , index-1);
}
public:
string toLower(string s) {
// code here
to_lower(s , s.size()-1);
return s;
}
};
//{ Driver Code Starts.
int main() {
int t;
cin >> t;
while (t--)
{
string s;
cin >> s;
Solution ob;
cout << ob.toLower(s) << endl;
}
return 0;
}
// } Driver Code Ends