mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 12:16:14 -04:00
Update and rename array-duplicate-zeros.py to duplicate_zeros_inplace.py
This commit is contained in:
parent
5c0e0228e6
commit
761c1f0670
@ -7,10 +7,7 @@
|
||||
|
||||
|
||||
def duplicate_zeros(arr: list[int]) -> list[int]:
|
||||
"""
|
||||
Do not return anything, modify arr in-place instead.
|
||||
"""
|
||||
|
||||
|
||||
i = 0
|
||||
while i < len(arr):
|
||||
|
||||
@ -27,11 +24,4 @@ def duplicate_zeros(arr: list[int]) -> list[int]:
|
||||
else:
|
||||
i += 1
|
||||
|
||||
|
||||
return arr
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
arr = [1, 0, 2, 3, 0, 4, 5, 0]
|
||||
print(duplicate_zeros(arr))
|
Loading…
x
Reference in New Issue
Block a user