Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
25 changes: 25 additions & 0 deletions solutions/jcalvarezj/solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
This module includes my solution to the challenge
"""
from typing import List


class Solution:
"""
This class represents a solution object that provides methods used to
compute a result
"""
def duplicate_zeros(self, arr: List[int]):
"""
This method duplicates the zeros inside the input array, while
respecting its original size
"""
initial_size = len(arr)
arr_enum = enumerate(arr.copy())
acumulate = 0
for i, num in arr_enum:
if num == 0:
arr.insert(i + acumulate + 1, 0)
acumulate += 1
for i in range(len(arr) - initial_size):
arr.pop()