mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-24 01:11:35 -04:00
add some int-cake problems
This commit is contained in:
parent
e04656170b
commit
fa83f7e42a
3 changed files with 86 additions and 0 deletions
13
interview_cake/reverse_in_place.py
Normal file
13
interview_cake/reverse_in_place.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
# 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))
|
Loading…
Add table
Add a link
Reference in a new issue