This problem is a part of LeetCode's Introduction to Data Structure Arrays - 101. This section covers the theoretical concepts related to Arrays fi...
For further actions, you may consider blocking this person and/or reporting abuse
"find the length of the maximum runs/groups of ones in a list"
Groups means check groupby for me and I came up with the following
Which returns 3.
a = [0,1, 0,1, 1, 1, 0, 1, 1]
streak = 0
count = 0
for (i in a) {
if (a[i] == 1) {
count++;
streak = Math.max(streak, count)
}
else {
count = 0
}
}
console.log(streak)
This works too.. But its in JS
Python is a multi paradigm language. A class with only one method is a code smell, try using a simpler function.
This is the default code skeleton on leetcode. You can have a look at it if you want.
Ah, then you just need to remember that it is a code smell, it just makes maintenence worse.