Skip to main content
9 events
when toggle format what by license comment
Oct 28, 2023 at 23:45 history edited Nate Anderson CC BY-SA 4.0
added 44 characters in body
Oct 28, 2023 at 13:28 comment added Nate Anderson I should read more, my challenge might be related to the maximum subarray problem -- notice some variations of the maximum subarray problem do allow an empty subarray to be summed to zero and address "non positive integers!" And there's the "max slice swap" challenge which feels even closer to my challenge because it allows a "swap" whereas my challenge allows one or more "deletes"
Oct 27, 2023 at 19:41 comment added MJ713 Also, I would argue that the result cannot be an empty array, because you cannot have a sum of no elements.
Oct 27, 2023 at 19:40 comment added MJ713 Actually, if we can use negative numbers, then the final array could have an even length as long as the last number is negative.
Oct 27, 2023 at 19:22 comment added Nate Anderson Yes that's thoughtful, thank you. That's what I realize in my answer here, where I "ignore" the last element (aka "drop it") like you suggest. But I like the way you put it, and it encourages me to think about the problem like "could the resulting array ever have zero elements in it?". (Maybe that would be necessary if the elements could be negative?... I'm not sure the original problem specifies that)
Oct 27, 2023 at 19:15 comment added MJ713 This is a useful insight: the final array must have an odd length. If it has an even length (>=2), then we can always increase S by dropping the last element.
Oct 27, 2023 at 18:55 history edited Nate Anderson CC BY-SA 4.0
added 1 character in body
S Oct 27, 2023 at 18:49 review First answers
Oct 27, 2023 at 19:32
S Oct 27, 2023 at 18:49 history answered Nate Anderson CC BY-SA 4.0