Python 2 lines or 1 line


  • -1
    G

    my code

      class Solution(object):
        def findRestaurant(self, list1, list2):
            minInd=min([list1.index(j)+list2.index(j) for j in set(list1)&set(list2)])
            return [i for i in set(list1)&set(list2) if list1.index(i)+list2.index(i)==minInd]
                
    

    and if you want 1 line ,then replace the minInd with the first code(but not necessary)


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.