FastPrepConstruct Distinct Integers Summing to Zero
Problems/Construct Distinct Integers Summing to Zero

Construct Distinct Integers Summing to Zero

Marshall Wace logoMarshall Wace● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Marshall Wace online assessment. Any valid array is accepted, including ones that are not made of opposite pairs. Our version is about 99% the same as the reported question.

Given an integer N, return an array containing exactly N distinct integers whose sum is zero.

You may return any array satisfying these conditions, in any order. There is no required pattern or particular range of values beyond the signed 32-bit integer return type.

Function

solution(N: int) → int[]

Examples

Example 1

N = 4return = [1,0,-3,2]

The four values are distinct and sum to zero. Another valid answer is [-2,1,-4,5]. The array [1,-1,1,3] is invalid: it repeats 1 and does not satisfy the conditions.

Example 2

N = 3return = [-1,0,1]

These three distinct values sum to zero. Other valid arrays are also accepted.

Example 3

N = 1return = [0]

This boundary example has only one element, which must be zero.

Constraints

  • 1 <= N <= 100.
  • For this exercise, return values are signed 32-bit integers.

More Marshall Wace Online Assessment questions

  • Count Letters with Ordered Lowercase and Uppercase OccurrencesOA · Seen Oct 2025
  • Maximum Trailing Zeros on a Path with at Most One TurnOA · Seen Oct 2025
  • Shortest Subarray Covering an Integer RangeOA · Seen Oct 2025
  • Maximum Events in a 60-Second WindowOA · Seen Aug 2025
  • Successful Logins from Multiple CountriesOA · Seen Aug 2025
  • Maximize Remaining Item Types After Clearing Consecutive ShelvesOA · Seen Nov 2024
  • Shortest String After Erasing Equal PairsOA · Seen Nov 2024
  • Count Distinct Tags in a Fixed-Radius Circle (Practice Reconstruction)OA · Seen Apr 2024
  • Generate Unique Company Email AddressesOA · Seen Apr 2024
  • Reconstruct a Two-Row Binary MatrixOA · Seen Apr 2024

Similar questions at other companies

  • Count Valid Square PairsAuxoAI · OA
  • Picked Player Who LostSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Server InvestmentRippling · OARippling interview questions
  • Basic Item DiscountsPalantir · OAPalantir interview questions
  • Next Pascal Row CoefficientIntuit · OAIntuit interview questions
  • Unique Integers That Sum to ZeroNVIDIA · OANVIDIA interview questions
  • Count Multiples of Three with Two SevensHudson River Trading · OAHudson River Trading interview questions
  • Diagonal Bounce TraversalAutodesk · OAAutodesk interview questions
  • Maximum Student-Teacher DistanceChubb · OAChubb interview questions
  • Maximum Three-Server Difficulty ScoreVisa · OAVisa interview questions

Interview reports that mention this question

  • Marshall Wace Older Quant Tests: 5 Experiences (Part 3 of 3)
  • Marshall Wace Quant and Coding OA: 19 Experiences (Part 1 of 3)

Marshall Wace interview experiences

  • Marshall Wace Coding Tests: 11 Experiences (Part 2 of 3)
All Marshall Wace interview questionsSee Marshall Wace hiring insights
Saved
class Solution {
    public int[] solution(int N) {
        // Write your solution here.
    }
}
N4
reference[1,0,-3,2]
Checking account…