human
Find a string which matches all the patterns in the given array | Function to find a common string which matches all the pattern.
For storing prefix till first most * without conflicts.
For storing suffix till last most * without conflicts.
For storing all middle characters between first and last *.
Loop to iterate over every pattern of the array.
Index of the first " * ".
Index of Last " * ".
Iterate over the first " * ".
Prefix till first most * without conflicts.
Iterate till last most * from last.
Make suffix till last most * without conflicts.
Take all middle characters in between first and last most *.
Driver Code.
Take all the strings.
Method for finding common string"
Solution in Python:
assistant
#Here is code to find a string which matches all the patterns in the given array and the other steps required.
 def find ( S , N ) :
	pref = " "
	suff = " "
	mid = " "
	for i in range ( N ) :
		first = int ( S [ i ] . index ( " * " ) )
		last = int ( S [ i ] . rindex ( " * " ) )
		for z in range ( len ( pref ) ) :
			if ( z < first ) :
				if ( pref [ z ] != S [ i ] [ z ] ) :
					return " * "
		for z in range ( len ( pref ) , first ) :
			pref += S [ i ] [ z ] ;
		for z in range ( len ( suff ) ) :
			if ( len ( S [ i ] ) - 1 - z > last ) :
				if ( suff [ z ] != S [ i ] [ len ( S [ i ] ) - 1 - z ] ) :
					return " * "
		for z in range ( len ( suff ) , len ( S [ i ] ) - 1 - last ) :
			suff += S [ i ] [ len ( S [ i ] ) - 1 - z ]
		for z in range ( first , last + 1 ) :
			if ( S [ i ] [ z ] != ' * ' ) :
				mid += S [ i ] [ z ]
	suff = suff [ : : - 1 ]
	return pref + mid + suff
N = 3
s = [ " " for i in range ( N ) ]
s [ 0 ] = " pq * du * q "
s [ 1 ] = " pq * abc * q "
s [ 2 ] = " p * d * q "
print ( find ( s , N ) )