human
Minimum Index Sum for Common Elements of Two Lists | Function to print common strings with minimum index sum.
resultant list.
iterating over sum in ascending order.
iterating over one list and check index ( Corresponding to given sum ) in other list.
put common strings in resultant list.
if common string found then break as we are considering index sums in increasing order ..
print the resultant list.
Creating list1.
Creating list2"
How can the above be solved in Python?
assistant
#Here is code to minimum Index Sum for Common Elements of Two Lists and the other steps required.
 def find ( list1 , list2 ) :
	res = [ ]
	max_possible_sum = len ( list1 ) + len ( list2 ) - 2
	for sum in range ( max_possible_sum + 1 ) :
		for i in range ( sum + 1 ) :
			if ( i < len ( list1 ) and ( sum - i ) < len ( list2 ) and list1 [ i ] == list2 [ sum - i ] ) :
				res . append ( list1 [ i ] )
		if ( len ( res ) > 0 ) :
			break
	for i in range ( len ( res ) ) :
		print ( res [ i ] , end = " ▁ " )
list1 = [ ]
list1 . append ( " GeeksforGeeks " )
list1 . append ( " Udemy " )
list1 . append ( " Coursera " )
list1 . append ( " edX " )
list2 = [ ]
list2 . append ( " Codecademy " )
list2 . append ( " Khan ▁ Academy " )
list2 . append ( " GeeksforGeeks " )
find ( list1 , list2 )