File tree 4 files changed +45
-5
lines changed
4 files changed +45
-5
lines changed Original file line number Diff line number Diff line change 1
1
# LeetCode Algorithms
2
2
3
- ![ problems-solved] ( https://img.shields.io/badge/Problems%20Solved-174 /2081-1f425f.svg )
4
- ![ problems-solved-java] ( https://img.shields.io/badge/Java-174 /2081-1abc9c.svg )
5
- ![ problems-solved-python] ( https://img.shields.io/badge/Python-174 /2081-1abc9c.svg )
3
+ ![ problems-solved] ( https://img.shields.io/badge/Problems%20Solved-175 /2081-1f425f.svg )
4
+ ![ problems-solved-java] ( https://img.shields.io/badge/Java-175 /2081-1abc9c.svg )
5
+ ![ problems-solved-python] (https://img.shields.io/badge/Python-175 /2081-1abc9c.svg)
6
6
[ ![ PRs Welcome] ( https://img.shields.io/badge/PRs-welcome-brightgreen.svg )] ( CONTRIBUTING.md )
7
7
[ ![ cp] ( https://img.shields.io/badge/also%20see-Competitve%20Programming-1f72ff.svg )] ( https://github.com/anishLearnsToCode/competitive-programming )
8
8
195
195
| 704 | [ Binary Search] ( https://leetcode.com/problems/binary-search ) | [ ![ Java] ( assets/java.png )] ( src/BinarySearch.java ) [ ![ Python] ( assets/python.png )] ( python/binary_search.py ) |
196
196
| 705 | [ Design HashSet] ( https://leetcode.com/problems/design-hashset ) | [ ![ Java] ( assets/java.png )] ( src/DesignHashSet.java ) [ ![ Python] ( assets/python.png )] ( python/design_hash_set.py ) |
197
197
| 706 | [ Design HashMap] ( https://leetcode.com/problems/design-hashmap ) | [ ![ Java] ( assets/java.png )] ( src/DesignHashMap.java ) [ ![ Python] ( assets/python.png )] ( python/design_hash_map.py ) |
198
- | 709 | [ To Lower Case] ( https://leetcode.com/problems/to-lower-case ) | |
198
+ | 709 | [ To Lower Case] ( https://leetcode.com/problems/to-lower-case ) | [ ![ Java ] ( assets/java.png )] ( src/ToLowerCase.java ) [ ![ Python ] ( assets/python.png )] ( python/to_lower_case.py ) |
199
199
| 716 | [ Max Stack] ( https://leetcode.com/problems/max-stack ) | |
200
200
| 717 | [ 1-bit and 2-bit Characters] ( https://leetcode.com/problems/1-bit-and-2-bit-characters ) | |
201
201
| 720 | [ Longest Word in Dictionary] ( https://leetcode.com/problems/longest-word-in-dictionary ) | |
Original file line number Diff line number Diff line change
1
+ class Solution :
2
+ def isAlphabet (self , character : str ) -> bool :
3
+ return self .isUpperCase (character ) or self .isLowerCase (character )
4
+
5
+ def isUpperCase (self , character : str ) -> bool :
6
+ return 65 <= ord (character ) <= 90
7
+
8
+ def isLowerCase (self , character : str ) -> bool :
9
+ return 97 <= ord (character ) <= 122
10
+
11
+ def toLowerCase (self , s : str ) -> str :
12
+ result = ''
13
+ for character in s :
14
+ result += chr (ord (character ) + 32 ) if self .isAlphabet (character ) and self .isUpperCase (character ) else character
15
+ return result
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ private void initializeBuckets() {
40
40
}
41
41
}
42
42
43
- private static class Bucket {
43
+ private class Bucket {
44
44
Queue <Integer > list = new LinkedList <>();
45
45
46
46
public boolean contains (int element ) {
Original file line number Diff line number Diff line change
1
+ public class ToLowerCase {
2
+ public String toLowerCase (String s ) {
3
+ StringBuilder result = new StringBuilder ();
4
+ for (int index = 0 ; index < s .length () ; index ++) {
5
+ result .append (toLowerCase (s .charAt (index )));
6
+ }
7
+ return result .toString ();
8
+ }
9
+
10
+ private char toLowerCase (char character ) {
11
+ return isUpperCase (character ) && isAlphabet (character ) ? (char ) (character + 32 ) : character ;
12
+ }
13
+
14
+ private boolean isAlphabet (char character ) {
15
+ return isUpperCase (character ) || isLowerCase (character );
16
+ }
17
+
18
+ private boolean isLowerCase (char character ) {
19
+ return 97 <= character && character <= 122 ;
20
+ }
21
+
22
+ private boolean isUpperCase (char character ) {
23
+ return 65 <= character && character <= 90 ;
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments