Python Forum
In linear time, find the maximum sum of all possible contiguous subarrays
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
In linear time, find the maximum sum of all possible contiguous subarrays
#15
(Oct-29-2021, 04:12 PM)deanhystad Wrote: Generate random lists of numbers and use the posted code(s) to compute the answer. You don't need an answer sheet when you have code that generates the correct answer.
Personally I think a lot of insight is gained by solving this problem by hand. I blanked on this problem until I wrote a list of numbers and a list of sums. I looked at that for about 10 seconds and the solution was immediately obvious.

Well , I did that of course, but maybe I'm missing something.
What should x = [-1,-2,-3,-4] yield ?
As I understand it : -1
Or are single values not allowed , although it is a "subarray".

Paul
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Reply


Messages In This Thread
RE: In linear time, find the maximum sum of all possible contiguous subarrays - by DPaul - Oct-29-2021, 05:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  find the header location in a .bin file without reading the whole file at a time SANJIB 0 2,263 Mar-05-2021, 04:08 PM
Last Post: SANJIB
  Find frequencies of an audio file at a specific time via librosa jberesford123__ 0 2,411 Oct-21-2020, 01:18 PM
Last Post: jberesford123__
  Find data using a period of time in SQLITE3 SmukasPlays 2 2,243 Jul-30-2020, 02:02 PM
Last Post: SmukasPlays
  Find if time is between start and end time mikke3141 3 2,332 Jan-03-2020, 08:48 PM
Last Post: mikke3141
  Find Maximum Flow for graph with infinite capacities Dav 6 4,364 Apr-16-2019, 02:08 PM
Last Post: Dav

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020