Question: Oracle || MNNIT Allahabad || Stable Segments || Cutting Metal Surplus (No Rest API Question was asked)
1
Entering edit mode

ADD COMMENTlink 14 months ago Anonymous • 10
1
Entering edit mode

https://www.geeksforgeeks.org/maximum-sum-subarray-such-that-start-and-end-values-are-same/

Find the prefix Sum.

For each i, check if pref_sum[i] - arr[i]  element is present int he prefix sum array which can be done using lower bound. and if its there then check the prev index element in the array if its equal to arr[i], then increment the ans.

 

T.c. O(nLogn). Do reply if it can be done in O(N) .

ADD COMMENTlink 13 months ago unicornme707 • 20

Login before adding your answer.

Similar Posts
Loading Similar Posts