Eric's Sequence

Problem Overview

  • Given p[0..n-1], find distinct integers a[0..n-1] so p[i] equals the count of j with a[i]+a[j]>0 for each i, and no pair (even same index) sums to 0.
  • Input: n and list p; Output: sequence a meeting the rules and minimizing max |a[i]|, or None if impossible; 1 ≤ n ≤ 100,000.
  • Domain: integer sequence construction from pairwise sum counts, relevant to algorithmic constraint reasoning.
  • This coding interview problem is an interview question from Codeium interviews.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: