Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solution(a)
- len = 1;
- max = 1;
- i = 1;
- while i<size(a,2)-1
- if a[i]*a[i+1]<=0
- len += 1
- while i < size(a, 2)-3
- if a[i]*a[i+2] >= 0
- len += 1
- if a[i+1]*a[i+3] >= 0
- len += 1
- i += 2
- else
- i += 1
- break
- end
- else break
- end
- end
- if len > max
- max=len
- end
- len = 1
- i+=2
- else
- i += 1
- end
- end
- return max
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement