Skip to content

Commit f6be977

Browse files
author
Milad Khoshdel
committed
refactor: optimize pythonic() by removing list() to improve performance
1 parent cad4754 commit f6be977

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

algorithms/strings/reverse_string.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ def iterative(s):
1414
return "".join(r)
1515

1616
def pythonic(s):
17-
r = list(reversed(s))
18-
return "".join(r)
17+
return "".join(reversed(s))
1918

2019
def ultra_pythonic(s):
2120
return s[::-1]

0 commit comments

Comments
 (0)