Practice Distribute Elements Into Two Arrays I
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Given nums, place its first element in arr1 and its second element in arr2. Process the remaining elements in order. Append the next value to arr1 if the last value in arr1 is greater than the last value in arr2; otherwise append it to arr2. Return arr1 followed by arr2.
Source: Distribute Elements Into Two Arrays I on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [2,1,3]
Output
[2,3,1]
# Example 2
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.
Related LeetCode Problems
Practice more problems similar to Distribute Elements Into Two Arrays I.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.