File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change 1
- Problem Statement : Given a string find the first duplicate word ,
2
- example string : “this is just a wonder , wonder why do I have this in mind ”
1
+ # Problem Statement : Given a string find the first duplicate word,
2
+ # example string: “this is just a wonder, wonder why do I have this in mind”
3
3
4
4
5
5
6
- - The right data - structure to check for existence :
7
- set in Python (order in not preserved )
6
+ # - The right data-structure to check for existence :
7
+ # set in Python (order in not preserved) -- NOT HashMap
8
8
9
9
10
- `` `
11
- string = "this is just a wonder, wonder why do I have this in mind"
12
10
def firstduplicate (string : str ) -> str :
13
11
import re
14
12
cleanStr = re .sub ("[^a-zA-Z -]" , "" , string )
@@ -21,6 +19,8 @@ def firstduplicate(string: str) -> str:
21
19
else :
22
20
seen_words .add (word )
23
21
return None
22
+
23
+ string = "this is just a wonder, wonder why do I have this in mind"
24
24
firstduplicate (string )
25
25
26
- `` `
26
+
You can’t perform that action at this time.
0 commit comments