Skip to content

Commit 726dd41

Browse files
author
ybenchekroun
authored
Update first_duplicate_word.py
1 parent fbcc38e commit 726dd41

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

HashMaps/first_duplicate_word.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
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”
33

44

55

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
88

99

10-
```
11-
string = "this is just a wonder, wonder why do I have this in mind"
1210
def firstduplicate(string: str) -> str:
1311
import re
1412
cleanStr = re.sub("[^a-zA-Z -]", "", string)
@@ -21,6 +19,8 @@ def firstduplicate(string: str) -> str:
2119
else:
2220
seen_words.add(word)
2321
return None
22+
23+
string = "this is just a wonder, wonder why do I have this in mind"
2424
firstduplicate(string)
2525

26-
```
26+

0 commit comments

Comments
 (0)