input: Write a python function to find the longest common prefix among a list of strings.
  assert lcp(["flower","flow","flight"]) == "fl"
  assert lcp(["dog","racecar","car"]) == ""
  assert lcp(["interspecies","interstellar","interstate"]) == "inters"
output: def lcp(strs):
      if not strs:
          return ""
      
      # Sort the list to get the smallest and largest string by lexicographical order
      strs.sort()
      
      # Compare characters of the first and last strings
      for i in range(len(strs[0])):
          if strs[0][i] != strs[-1][i]:
              return strs[0][:i]
      
      return strs[0]