CSES- Maximum Subarray II | Why is this code giving correct answer?

Revision en5, by Rock2000, 2020-08-26 18:10:30

The first code is giving correct answer while second code is giving wrong answer. The only difference between these two codes is:
In the first code the return value is -2*inf in the getmax function while it is -inf in the second code. Can anybody please help me figure out what is the problem?

Code 1
Code 2
Tags cses, maximum subarray sum

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en6 English Rock2000 2020-08-26 18:23:21 66
en5 English Rock2000 2020-08-26 18:10:30 10
en4 English Rock2000 2020-08-26 17:59:58 2 Tiny change: 'isThe first ' -> 'The first '
en3 English Rock2000 2020-08-26 17:59:08 3
en2 English Rock2000 2020-08-26 17:58:30 13 Tiny change: 'The first ' -> 'isThe first '
en1 English Rock2000 2020-08-26 17:57:55 4405 Initial revision (published)