+ 2
Method that takes a Boolean array and returns true if the longest run of true values is greater than consecutive false values.
A run of true values is a set of adjacent elements all which contain the value true. If run of True values is not greater than run of false values return false. You can assume that a longest run of either true or false exists in the array.
6 ответов
+ 1
https://code.sololearn.com/ctcs8SX3eT68/?ref=app
+ 1
@Adam Schmitt I think it works for the most part, but not always for example if you try passing this array to the method:
true, false, false, false, false, true, false, true, true, true, true, true
it would return false, when it should return true. Since longest false run is 4 and longest true run is 5
+ 1
@danat gorth Thanks for the tip. I had the increment to the array index set based on the absolute position of the run instead of the length of the run. The bug is now fixed and your example was added to illustrate the change.
+ 1
@Adam Schmitt thanks it works.
0
This is my attempt at it, haven't fully tested it but have tried a few scenarios.
https://code.sololearn.com/cZz2V9yIL1d7/?ref=app