Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion strings/remove_duplicate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from collections import OrderedDict

def remove_duplicates(sentence: str) -> str:

Check failure on line 3 in strings/remove_duplicate.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

strings/remove_duplicate.py:1:1: I001 Import block is un-sorted or un-formatted
"""
Remove duplicates from sentence
>>> remove_duplicates("Python is great and Java is also great")
Expand All @@ -6,7 +8,7 @@
>>> remove_duplicates("Python is great and Java is also great")
'Java Python also and great is'
"""
return " ".join(sorted(set(sentence.split())))
return " ".join(list(OrderedDict.fromkeys(sentence.split())))


if __name__ == "__main__":
Expand Down
Loading