Distribute Elements Into Two Arrays I Problem
Distribute Elements Into Two Arrays I Problem — ExecCode Easy DSA Practice
Solve the Distribute Elements Into Two Arrays I problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given a 1-indexed array of distinct integers nums of length n. Your task is to compute the required answer and return the array result. You need to distribute all the elements of nums between two arrays arr1 and arr2 using n operations. In the first operation, append nums[1] to arr1. In the second operation, append nums[2] to arr2. Afterwards, in the i^th operation:.
Examples
Input {"nums": [2, 1, 3]}; Output [2, 3, 1]. Input {"nums": [5, 4, 3, 8]}; Output [5, 3, 4, 8]
Constraints
3 <= n <= 50 1 <= nums[i] <= 100 All elements in nums are distinct.
Practice Distribute Elements Into Two Arrays I free on ExecCode. Browse DSA problems, topic map, and placement guides.