input: Write a python function to generate all permutations of a given list.
  assert permute(['a', 'b', 'c']) == [['a', 'b', 'c'], ['a', 'c', 'b'], ['b', 'a', 'c'], ['b', 'c', 'a'], ['c', 'a', 'b'], ['c', 'b', 'a']]
  assert permute([1, 2]) == [[1, 2], [2, 1]]
  assert permute([1]) == [[1]]
output: def permute(lst):
      def backtrack(first=0):
          if first == n:
              output.append(lst[:])
          for i in range(first, n):
              lst[first], lst[i] = lst[i], lst[first]
              backtrack(first + 1)
              lst[first], lst[i] = lst[i], lst[first]
  
      n = len(lst)
      output = []
      backtrack()
      return output