aboutsummaryrefslogtreecommitdiff
path: root/challenge-264/lubos-kolouch/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-264/lubos-kolouch/python/ch-2.py')
-rw-r--r--challenge-264/lubos-kolouch/python/ch-2.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/challenge-264/lubos-kolouch/python/ch-2.py b/challenge-264/lubos-kolouch/python/ch-2.py
new file mode 100644
index 0000000000..64b092793c
--- /dev/null
+++ b/challenge-264/lubos-kolouch/python/ch-2.py
@@ -0,0 +1,12 @@
+from typing import List
+
+def create_target_array(source: List[int], indices: List[int]) -> List[int]:
+ target = []
+ for s, i in zip(source, indices):
+ target.insert(i, s)
+ return target
+
+# Test the function
+assert create_target_array([0, 1, 2, 3, 4], [0, 1, 2, 2, 1]) == [0, 4, 1, 3, 2]
+assert create_target_array([1, 2, 3, 4, 0], [0, 1, 2, 3, 0]) == [0, 1, 2, 3, 4]
+assert create_target_array([1], [0]) == [1]