Finding highest contiguous sum
def max_sequence(arr):
max = 0
curr = 0
for i in arr:
curr +=i
if curr < 0:
curr=0
if curr > max:
max = curr
return max
Search for a command to run...
def max_sequence(arr):
max = 0
curr = 0
for i in arr:
curr +=i
if curr < 0:
curr=0
if curr > max:
max = curr
return max
No comments yet. Be the first to comment.
Understanding Cyclic Sequence Patterns in JavaScript When working with arrays, there are times when you might want to iterate over the elements more than once in a cyclic manner. This means that after reaching the last element of the array, the itera...
Today I've learnt about object parameter destructuring and I'm surprised I never knew about it till today. Its where you destructure an object into a function by directly entering the key within curly brackets. Normal destructuring uses the normal fo...
Rendering JSX elements stored in variables I have been studying React Js this past week and it has been surprisingly quite simple (so far) but one if my key takeaways from today's content has been how you can render JSX elements that have been stored...
Working with event listeners For the past week I've been working on my final school project and something that had been a bit of a challenge for me ended up being event listeners. Over the course of a few assignments that I had been doing, I simply d...
