We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- All Contests
- HourRank 26
- Pair Sums
- Discussions
Pair Sums
Pair Sums
Sort by
recency
|
10 Discussions
|
Please Login in order to post a comment
Can anyone here help me correct this solution??
i had tried a dynamic programming approach with dp[n][n] and time complexity O(n^2) but this be able to pass only 7/21 test cases.As dp[100000][100000]could be a problem what could be an alternative to such a large 2D array
Contest is over, so I'm allowed to post code, right? Here's my partially correct solution. I would be very grateful if someone could help me with this.
I find the maximum value of arrays A[0:i] for all i and just "assume" A[max_i] is an endpoint of the desired subarray. Then I just find the maximum value of arrays containing one of those endpoints.
Surprisingly, this passes for 70.4/80 points (18/21 correct). Is this because of generous test cases? Also, is A = [0,0,...,0] the only worst-case for this algorithm?
Try 5 7 -5 6 3 9 as subarray.
Is the sub array a contiguous one or any of the elements of array?