A repository to get started with open source and contribute in Hacktoberfest . You can add any data structures and algorithms code in the language of your choice.
16
stars
80
forks
source link
maximum circular subarray using kadane's algorithm.cpp #142
using kadane's algorithm we find the maximum sum of circular subarray .the contributing elements to the maxsum are wrapping .In this case, we change wrapping to non-wrapping..so find out the sum of non-contributing elements and subtract this sum from the total sum. To find out the sum of non-contributions, invert the sign of each element and then run Kadane’s algorithm.in kadane's algo non-wrapping elements give maxsum. but here contributing elements give but we convert them to non contributing by inverting sign an applying kadane's go through the code to understand better with comments
using kadane's algorithm we find the maximum sum of circular subarray .the contributing elements to the maxsum are wrapping .In this case, we change wrapping to non-wrapping..so find out the sum of non-contributing elements and subtract this sum from the total sum. To find out the sum of non-contributions, invert the sign of each element and then run Kadane’s algorithm.in kadane's algo non-wrapping elements give maxsum. but here contributing elements give but we convert them to non contributing by inverting sign an applying kadane's go through the code to understand better with comments