mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 20:26:07 -04:00
13 lines
278 B
Python
13 lines
278 B
Python
# Write a function that takes a list of characters and reverses the letters in place.
|
|
# O(n) time and O(1)O(1) space.
|
|
|
|
def reverse_in_place(char_list):
|
|
return char_list[::-1]
|
|
|
|
|
|
char_list = ['a', 'b', 'c', 'd', 'e', 'f']
|
|
|
|
|
|
|
|
print(char_list)
|
|
print(reverse_in_place(char_list)) |