Pregunta de entrevista de Meta

# Question 3: # Complete a function that returns a list containing all the mismatched words (case sensitive) between two given input strings # For example: # - string 1 : "Firstly this is the first string" # - string 2 : "Next is the second string" # # - output : ['Firstly', 'this', 'first', 'Next', 'second']

Respuestas de entrevistas

Anónimo

31 jul 2020

def findDif(s1,s2): set1=set(s1.split()) set2=set(s2.split()) return set1 ^ set 2

8

Anónimo

16 jun 2020

string1 = "Firstly this is the first string" string2 = "Next is the second string" s1 = set(string1.split()) s2 = set(string2.split()) ls = sorted(list(s1.symmetric_difference(s2))) print("common words list: ",s1&s2) print("uncommon words list: ",ls)

2

Anónimo

2 sep 2020

print(list(set(A.split()).symmetric_difference(set(B.split()))))

1

Anónimo

5 feb 2025

### solution: def return_mismatched_words(str1, str2): # Write your code here str1 = str1.split() str2 = str2.split() words = str1 + str2 mismatched_words = [] for word in words: if words.count(word) < 2: mismatched_words.append(word) return mismatched_words

Anónimo

13 jul 2020

def mismatched_words(string1, string2): string1 = set(string1.split()) string2 = set(string2.split()) return list(string1 - string2) + list(string2 - string1)

Anónimo

28 jul 2020

def findDif(s1,s2): l1=s1.split() l2=s2.split() l3= set(l1+l2) for i in l1: for j in l2: if l1[i]==l2[j]: l3.remove(l1[i]) return l3