@RyanMarcus/

lowest_subseq_sum

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
def best_subsequence(a): 
    best_so_far = 10000000000
    best_ending_at_curr = 0

    for val in a:
        best_ending_at_curr = best_ending_at_curr + val

        if best_ending_at_curr < best_so_far:
            best_so_far = best_ending_at_curr

        if best_ending_at_curr > 0:
            best_ending_at_curr = 0
    
    return best_so_far
   

a = [1,3,-2,1,-2,4]
print(best_subsequence(a))