Ethos Software Engineer Interview Experience — Online Assessment on Recoverable Elements from Range-Sum Queries

Ethos·Software Engineer·Aug 2026
Online Assessmentmedium

Recoverable Elements from Range-Sum Queries

You are given an unknown integer array A of length N, with elements indexed from 1 to N.
You will receive Q range-sum queries. Each query contains two integers L and R, and gives you the sum of all elements of A from index L to index R.
Your task is to use the given query information to find all the elements A[i] whose exact value can be uniquely determined. If the value of an element A[i] can be uniquely computed from the given range sums, it is called recoverable.

Input and output requirements:

  1. The first line of input contains two integers N and Q, the array length and the number of queries.
  2. The next Q lines each contain two integers L and R, representing one known range sum.
  3. Output all 1-based element indices i whose values can be uniquely determined, in ascending order, separated by spaces.
  4. If no element can be uniquely determined, output -1.

Constraints:

  1. 1 <= N <= 10^5
  2. 1 <= Q <= 10^5
  3. 1 <= L <= R <= N

Published

Curated and edited by PracHub

Practice the questions from this interview

Discussion

Sign in to join the discussion. The author is notified of every comment.

Loading comments…

Interview at a glance

Company
Ethos
Role
Software Engineer
Rounds
Online Assessment
Difficulty
medium
Interview date
Aug 2026
Questions from this interview
1 question

Real Ethos interview experiences

First-hand reports from Ethos candidates — the rounds, the questions they were asked, and how it went.

All 6 Ethos interview experiences