input: from typing import List
  
  def longest_increasing_or_decreasing_subarray(nums: List[int]) -> int:
      """
      Given an array of integers, find the length of the longest subarray where the elements are either strictly increasing or 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:     
      if not nums:
          return 0
  
      max_length = 1
      current_length = 1
      increasing = None
  
      for i in range(1, len(nums)):
          if nums[i] > nums[i - 1]:
              if increasing is False:
                  current_length = 1
              current_length += 1
              increasing = True
          elif nums[i] < nums[i - 1]:
              if increasing is True:
                  current_length = 1
              current_length += 1
              increasing = False
          else:
              current_length = 1
              increasing = None
  
          max_length = max(max_length, current_length)
  
      return max_length
  