3618. Split Array by Prime Indices
You are given an integer array
nums.Split
numsinto two arraysAandBusing the following rule:
- Elements at prime indices in
numsmust go into arrayA.- All other elements must go into array
B.Return the absolute difference between the sums of the two arrays:
|sum(A) - sum(B)|.A prime number is a natural number greater than 1 with only two factors, 1 and itself.
Note: An empty array has a sum of 0.
1 | int factors[101010]; |