Anonymous
BAN USER
Comments (14)
Reputation -5
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
@elaas.eyitoohc.
Once you have computed the C array by doing A[i] - B[j], What will be your algorithm to identify i and j such that (j-i) is largest and C[i] + C[i+1]...+C[j] = 0? If you try out all the possible combinations of i and j such that 0<=i<n and 0<=j<n, then your algorithm will be of complexity O(n^2).
Hope you understand it at least now. BTW, you are a gifted "ayitoohc"
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
-1
of 1 vote
C[i] = A[i] - B[i].??
This won't work. The contiguous subarray sum of A and B might be equal, but C[i] need not be zero. Consider the case:
A = 0101
B = 1010
Then C would be -11-11. C is not zero here, but you still have got a subarrays in A and B whose sums are equal
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Bad Solution
- Anonymous August 21, 2013