lingalarahul7
BAN USER
Comments (4)
Reputation 10
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
Your solution is wrong when minimum subarray is contained in the maximum subarray.
Eg : 201, -100, 200, -99
Maximum subarray is 201 + -100 + 200 = 301
Minimum subarray is -100
According to solution is max(201, 200)-(-100) = 301
But, consider subarray as 201, -100, 200 and the other subarray as -99
Answer would be 301-(-99) = 400
Comment hidden because of low score. Click to expand.
0
of 0 vote
Can you give you a proof to the above explanation?
It seems valid, but I'm unable to prove it.
Comment hidden because of low score. Click to expand.
0
of 0 vote
This can take O(size^2) time if the given value of N is size/2
- lingalarahul7 June 10, 2015Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Updating max-heap would take log(n) time, my friend.
- lingalarahul7 June 19, 2015