# Problem Statement
You are given an array of integers `nums`. Return _the length of the **longest**
subarray_ of `nums` _which is either **strictly increasing** or **strictly decreasing**_.
## Constraints
- `1 <= nums.length <= 50`
- `1 <= nums[i] <= 50`
# Solution
Because of the low constraints, we can brute-force this problem and generate all subarrays. For each of the generated subarrays, we can check if it is strictly increasing or decreasing and then update our answer accordingly.
> [!DANGER] Alert!
> This is not the optimal solution!
```python
ans = 0
def strict(nums):
p = list(pairwise(nums))
return all([a<b for a,b in p]) or all([a>b for a,b in p])
for i in range(len(nums)):
for j in range(i+1, len(nums)+1):
if strict(nums[i:j]):
ans = max(ans, j-i)
return ans
```
Time Complexity: O$(n^2)$ | Space Complexity: $O(n)$