Largest Sum Contiguous Subarray

We have a sequence of integers and we need the maximum sum from the continuous sub-sequences. Example- Let the sequence of integers be (3,-4,5,-7,8,-6,21,-14,-9,19). Then,the sub-array or sub-sequence with maximum sum is (8,-6,21) and the maximum sum is 23. Brute Force- We can check sums of all sequences of different sizes from 1 to N.Its […]

Continue reading →

Subarray with given sum

Given a list of integers,our task is to find if a sub-sequence which adds to a given number exists or not. Example- The given list is (1,4,20,5,5) and the given number or sum is 29. Then,the sub-sequence which adds to 29 is (4,20,5). Brute Force- All the sub-sequences are considered and its sum is compared […]

Continue reading →