File tree 2 files changed +69
-0
lines changed
2024-05-May-LeetCoding-Challenge
2 files changed +69
-0
lines changed Original file line number Diff line number Diff line change
1
+ # April-LeetCoding-Challenge-2024
2
+
3
+ ## Questions
4
+ | Day | Problem | Level | Status |
5
+ | --- | --- | --- | --- |
6
+ | May 1 | [ 2000. Reverse Prefix of Word] ( https://leetcode.com/problems/reverse-prefix-of-word/ ) | Easy | Solved |
7
+ | May 2 | [ ] ( ) | | |
8
+ | May 3 | [ ] ( ) | | |
9
+ | May 4 | [ ] ( ) | | |
10
+ | May 5 | [ ] ( ) | | |
11
+ | May 6 | [ ] ( ) | | |
12
+ | May 7 | [ ] ( ) | | |
13
+ | May 8 | [ ] ( ) | | |
14
+ | May 9 | [ ] ( ) | | |
15
+ | May 10 | [ ] ( ) | | |
16
+ | May 11 | [ ] ( ) | | |
17
+ | May 12 | [ ] ( ) | | |
18
+ | May 13 | [ ] ( ) | | |
19
+ | May 14 | [ ] ( ) | | |
20
+ | May 15 | [ ] ( ) | | |
21
+ | May 16 | [ ] ( ) | | |
22
+ | May 17 | [ ] ( ) | | |
23
+ | May 18 | [ ] ( ) | | |
24
+ | May 19 | [ ] ( ) | | |
25
+ | May 20 | [ ] ( ) | | |
26
+ | May 21 | [ ] ( ) | | |
27
+ | May 22 | [ ] ( ) | | |
28
+ | May 23 | [ ] ( ) | | |
29
+ | May 24 | [ ] ( ) | | |
30
+ | May 25 | [ ] ( ) | | |
31
+ | May 26 | [ ] ( ) | | |
32
+ | May 27 | [ ] ( ) | | |
33
+ | May 28 | [ ] ( ) | | |
34
+ | May 29 | [ ] ( ) | | |
35
+ | May 30 | [ ] ( ) | | |
36
+ | May 31 | [ ] ( ) | | |
37
+
38
+
39
+ ## Summary
40
+ | Level | Problems | Solved | Unsolved |
41
+ | --- | --- | --- | --- |
42
+ | Easy | 1 | 1 | 0 |
43
+ | Medium | 0 | 0 | 0 |
44
+ | Hard | 0 | 0 | 0 |
Original file line number Diff line number Diff line change
1
+ class Solution :
2
+ def reversePrefix (self , word : str , ch : str ) -> str :
3
+ try :
4
+ idx = word .index (ch )
5
+ except ValueError :
6
+ return word
7
+ return word [:idx + 1 ][::- 1 ] + word [idx + 1 :]
8
+
9
+
10
+ def main ():
11
+ word = "abcdefd"
12
+ ch = "d"
13
+ assert Solution ().reversePrefix (word , ch ) == "dcbaefd"
14
+
15
+ word = "xyxzxe"
16
+ ch = "z"
17
+ assert Solution ().reversePrefix (word , ch ) == "zxyxxe"
18
+
19
+ word = "abcd"
20
+ ch = "z"
21
+ assert Solution ().reversePrefix (word , ch ) == "abcd"
22
+
23
+
24
+ if __name__ == '__main__' :
25
+ main ()
You can’t perform that action at this time.
0 commit comments