Lesson : 9-1 - Maximum slice problem | MaxDoubleSliceSum | Codility for Programmer | Java

preview_player
Показать описание

#MaxDoubleSliceSum #Algorithm #Codility
Рекомендации по теме
Комментарии
Автор

You can do it in one loop, by remembering the current lowest value in the current double slice, and swapping it out with the current value if the current value is lower

paulwiseman
Автор

thanks, it helped a lot. I think your explanations would be much clear if you use real values to show what is happening, something like a virtual board or even some IDE debug.

sheldonoliveira
Автор

why compare with 0?
Math.max(0, A[i] + maxSum).

Kadane's Algorithm should be
Math.max(A[i], A[i] + maxSum).
it should have A[i] instead of 0.

fredteixeira