Question: Consider the following problem: INPUT: An array A of length n. OUTPUT: A pair of indices (1,j), with ; ? i such that Dk=i =

Consider the following problem: INPUT: An array A of length n. OUTPUT: A pair of indices (1,j), with ; ? i such that Dk=i = A[i] + Ai + 1] + ... + A[j] = 100, or "no solution" if no such pair of indices exists. (If there exist many such pair of indices i, j, you only have to return one of them.) Give an O(n) time algorithm for this
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
