Company: Zomato

Difficulty: medium

Problem Statement

Deducible Elements from Range-Sum Hints An unknown integer array A has N elements. You receive Q hints. A hint L R S states that the exact sum A[L] + A[L+1] + ... + A[R] equals S . Determine every index whose individual value is uniquely fixed by the hints. Print the indices in increasing order. Input Format The first line contains N and Q . Each of the next Q lines contains L , R , and S . Output Format Print the deducible indices in increasing order, separated by spaces. If none are deducible, print -1 . Constraints 1 <= N, Q <= 100000 1 <= L <= R <= N -10^18 <= S <= 10^18 The hints are mutually consistent with at least one integer array. Indices are 1-based. Example Input: 4 3 1 2 7 2 2 3 1 3 12 Output: 1 2 3 The second hint gives A[2] = 3 . The first then gives A[1] = 4 , and the third gives A[3] = 5 . No hint isolates A[4] . Notes Only uniqueness matters; the element values themselves are not printed. A value is deducible when all arrays satisfying every hint

More Zomato OA questionsInterview experiences