diff --git a/.gitignore b/.gitignore index b33d783..6e17493 100644 --- a/.gitignore +++ b/.gitignore @@ -129,4 +129,5 @@ dmypy.json .pyre/ # VSCode -.vscode/ \ No newline at end of file +.vscode/ +main.py diff --git a/solutions/wilson_romero/__init__.py b/solutions/wilson_romero/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/solutions/wilson_romero/solution.py b/solutions/wilson_romero/solution.py new file mode 100644 index 0000000..d4aca88 --- /dev/null +++ b/solutions/wilson_romero/solution.py @@ -0,0 +1,19 @@ +""" Module solution """ +from typing import List + + +class Solution: + """ Challenge solution """ + + def duplicate_zeros(self, arr: List[int]): + """Duplicate zeros and shift right""" + length = len(arr) + zeros = [] + for step, value in enumerate(arr): + if value == 0: + zeros.append(step) + + length_zeros = len(zeros) + if 0 < length_zeros < length: + for step, value in enumerate(zeros): + arr[value + step + 1:] = arr[value + step:-1]