mediumArrayMathNumber Theory 0 views
Split Array by Prime Indices
You are given an integer array nums.
You are given an integer array nums.
Split nums into two arrays A and B using the following rule:
Return the absolute difference between the sums of the two arrays: |sum(A) - sum(B)|.
Note: An empty array has a sum of 0.
Example 1
Input: nums = [2,3,4]
Output: 1
Example 2
Input: nums = [-1,5,7,0]
Output: 3
Constraints
- 1 <= nums.length <= 10^5
- -10^9 <= nums[i] <= 10^9
Hints
Companies
No companies reported yet.
Discussion
Sign in to join the discussion.
Loading discussion...
Test results
No test cases yet.