-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTolowercase.java
More file actions
50 lines (38 loc) · 785 Bytes
/
Copy pathTolowercase.java
File metadata and controls
50 lines (38 loc) · 785 Bytes
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
/*
709. To Lower Case
Solved
Easy
Topics
premium lock icon
Companies
Hint
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: "here"
Example 3:
Input: s = "LOVELY"
Output: "lovely"
Constraints:
1 <= s.length <= 100
s consists of printable ASCII characters. */
class Solution {
public String toLowerCase(String s) {
StringBuilder sb = new StringBuilder();
for(int i=0;i<s.length();i++)
{
char c=s.charAt(i);
if(c>='A'&&c<='Z')
{
c=(char)(c+32);
}
sb.append(c);
}
return sb.toString();
}
}
//tc=o(n)
//sc=o(n)