[
array
]
BinarySearch 1016 Strictly Alternating List
Problem statement
https://binarysearch.com/problems/Strictly-Alternating-List/
Solution
Just do what is asked: not two equal elements adjacent and A[0] < A[1]
.
Complexity
It is O(n)
for time and space.
Code
class Solution:
def solve(self, A):
return all(x != y for x, y in zip(A, A[1:])) and A[0] < A[1]