input: from typing import List
  
  def longest_monotonic_subarray(nums: List[int]) -> int:
      """
      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.
  
      Examples:
      >>> nums = [1,4,3,3,2]
      2
  
      >>> nums = [3,3,3,3]
      1
  
      >>> nums = [3,2,1]
      3
  
      Constraints:
      1 <= nums.length <= 50
      1 <= nums[i] <= 50
      """
  
output:     n = len(nums)
      if n == 1:
          return 1
      
      increasing = [1] * n
      decreasing = [1] * n
      
      for i in range(1, n):
          if nums[i] > nums[i - 1]:
              increasing[i] = increasing[i - 1] + 1
          if nums[i] < nums[i - 1]:
              decreasing[i] = decreasing[i - 1] + 1
      
      max_length = 1
      for i in range(n):
          max_length = max(max_length, increasing[i], decreasing[i])
      
      return max_length