human
Write me a code to longest Common Prefix using Sorting and the other steps required given the following:
Longest Common Prefix using Sorting | Python 3 program to find longest common prefix of given array of words ..
if size is 0 , return empty string.
sort the array of strings.
find the minimum length from first and last string.
find the common prefix between the first and last string.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to longest Common Prefix using Sorting and the other steps required.
 def longestCommonPrefix ( a ) :
	size = len ( a )
	if ( size == 0 ) :
		return " "
	if ( size == 1 ) :
		return a [ 0 ]
	a . sort ( )
	end = min ( len ( a [ 0 ] ) , len ( a [ size - 1 ] ) )
	i = 0
	while ( i < end and a [ 0 ] [ i ] == a [ size - 1 ] [ i ] ) :
		i += 1
	pre = a [ 0 ] [ 0 : i ]
	return pre
if __name__ == " _ _ main _ _ " :
	input = [ " geeksforgeeks " , " geeks " , " geek " , " geezer " ]
	print ( " The ▁ longest ▁ Common ▁ Prefix ▁ is ▁ : " , longestCommonPrefix ( input ) )