Sum It Up 3

Discuss about the puzzles, but without giving the solutions please !!!

Sum It Up 3

Postby admin » Wed Jan 05, 2011 8:50 am

You are given an array of integers (both positive and negative). Find the contiguous sequence with the largest sum. Return the sum.


Last edited by admin on Mon Mar 28, 2011 4:37 pm, edited 3 times in total.
Reason: Edit
User avatar
admin
Site Admin
 
Posts: 333
Joined: Thu Dec 23, 2010 1:27 am

Re: Sum It Up 3

Postby Hiidw Ana » Fri Jan 21, 2011 10:55 am

I've solved this puzzle. i've tested with sample input & succeeded.also the source code editor is displaying "Verification succeeded". but when i submitted the solution, it's status is showing "Fail". Can u plz resolve this?
User avatar
Hiidw Ana
 
Posts: 2
Joined: Tue Jan 18, 2011 12:34 am

Re: Sum It Up 3

Postby admin » Fri Jan 21, 2011 1:28 pm

I just checked your report.
If you look at the report, there's a table which shows the reason for each test failure.

In your case, it says "Segmentation Fault", if you follow the link of this message, it'll give you a more detailed explanation of the problem.

May be you're not allocating enough memory to store the values of the array for example.
User avatar
admin
Site Admin
 
Posts: 333
Joined: Thu Dec 23, 2010 1:27 am

Re: Sum It Up 3

Postby Hiidw Ana » Sat Jan 22, 2011 5:51 am

Thnx very much. I've passed. My code was same was before only I used vector<int> istead of predefined array.

Thnx a lot again
User avatar
Hiidw Ana
 
Posts: 2
Joined: Tue Jan 18, 2011 12:34 am

Re: Sum It Up 3

Postby carel.jonkhout » Mon Mar 28, 2011 3:16 pm

What exacty do you mean by 'continous series' ? Could you explain it a bit more with a slightly bigger example? I understand that you don't want to give away any spoilers, but I am a little confused. I can't see why you would need a 1000mb memory to detect a sequence. I've tried two simple ways, but i got an 'incorrect result' ( detecting a sequence of the same numbers and a sequence of a sequence of number each one bigger than the last. )
User avatar
carel.jonkhout
 
Posts: 9
Joined: Sun Feb 27, 2011 7:52 pm

Re: Sum It Up 3

Postby admin » Mon Mar 28, 2011 4:37 pm

By continuous series, we mean that the numbers must be next to each others. Actually the description should say "contiguous" and not continuous, I'll edit it right way.

Here's another example:
1 2 3 -1 4 -10 8

The answer should be: 9
Since 1 + 2 + 3 - 1 + 4 = 9
That's most you can get by selecting a contiguous sequence of numbers.
User avatar
admin
Site Admin
 
Posts: 333
Joined: Thu Dec 23, 2010 1:27 am


Return to Puzzles

Who is online

Users browsing this forum: No registered users and 2 guests

cron