Solve an easy or medium algorithm problem involving arrays of strings, and explain your approach and complexity.
Implement longest_common_prefix(strings). Given an array of strings, return the longest string that appears as a prefix of every element. Return an empty string when no common prefix exists.
The input is an array of strings, and the output is a string. State the time and auxiliary-space complexity of your solution.
def longest_common_prefix(strings):