input: 
  from typing import List
  
  
  def linear_search(arr: List[int], x: int) -> int:
      """Optimizes the linear search implementation by using enumerate to both iterate over the array and get the index.
      >>> linear_search([1, 2, 3, 4], 3)
      2
      >>> linear_search([1, 2, 3, 4], 5)
      -1
      >>> linear_search([], 0)
      -1
      """
      for index, item in enumerate(arr):
          if item == x:
              return index
      return -1
  
output:     for index, item in enumerate(arr):
          if item == x:
              return index
      return -1