Company: Zomato

Difficulty: medium

Problem Statement

Decoding the Secret Code You are given an unknown integer array A of length N and Q known range-sum relations. Each relation [L, R] means that the exact value of A[L] + A[L+1] + ... + A[R] is known. For this task, only the ranges are supplied: the numeric sums do not affect which individual array elements can be uniquely deduced. Determine every index i for which A[i] is uniquely determined by the set of relations, and print those indices in increasing order. Input Format The first line contains two integers N and Q . Each of the next Q lines contains two integers L and R , describing a known range sum. Output Format Print all deducible indices in increasing order on one line, separated by spaces. If no index is deducible, print -1 . Constraints 1 <= N, Q <= 100000 1 <= L <= R <= N All indices are 1-based. Repeated ranges are allowed and do not change the answer. Examples Example 1 Input: 3 3 1 2 2 2 1 3 Output: 1 2 3 The known sums let us deduce the second element direc

More Zomato OA questionsInterview experiences