File tree Expand file tree Collapse file tree 1 file changed +14
-14
lines changed
Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Original file line number Diff line number Diff line change 11def remove_duplicates (sentence : str ) -> str :
22 """
33 Remove duplicates from sentence and return words in sorted order
4-
4+
55 Args:
66 sentence: Input string containing words separated by spaces
7-
7+
88 Returns:
99 String with unique words sorted alphabetically
10-
10+
1111 Examples:
1212 Basic functionality:
1313 >>> remove_duplicates("Python is great and Java is also great")
1414 'Java Python also and great is'
15-
15+
1616 Multiple spaces handling:
1717 >>> remove_duplicates("Python is great and Java is also great")
1818 'Java Python also and great is'
19-
19+
2020 Edge cases:
2121 >>> remove_duplicates("")
2222 ''
23-
23+
2424 >>> remove_duplicates(" ")
2525 ''
26-
26+
2727 >>> remove_duplicates("hello")
2828 'hello'
29-
29+
3030 >>> remove_duplicates("hello hello hello")
3131 'hello'
32-
32+
3333 Mixed case (case sensitive):
3434 >>> remove_duplicates("Python python PYTHON")
3535 'PYTHON Python python'
36-
36+
3737 Numbers and special characters:
3838 >>> remove_duplicates("1 2 3 1 2 3")
3939 '1 2 3'
40-
40+
4141 >>> remove_duplicates("hello world hello world!")
4242 'hello world world!'
43-
43+
4444 Single character words:
4545 >>> remove_duplicates("a b c a b c")
4646 'a b c'
47-
47+
4848 Mixed content:
4949 >>> remove_duplicates("The quick brown fox jumps over the lazy dog")
5050 'The brown dog fox jumps lazy over quick the'
@@ -55,4 +55,4 @@ def remove_duplicates(sentence: str) -> str:
5555if __name__ == "__main__" :
5656 import doctest
5757
58- doctest .testmod ()
58+ doctest .testmod ()
You can’t perform that action at this time.
0 commit comments