-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReturn Mismatched Words.txt
36 lines (31 loc) · 1.26 KB
/
Return Mismatched Words.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Given an input of two strings consisting of english letters (a-z; A-Z) and spaces, complete a function that returns a list containing all the mismatched words (case sensitive) between them.
You can assume that a word is a group of characters delimited by spaces.
A mismatched word is a word that is only in one string but not the other.
Add mismatched words from the first string before you add mismatched words from the second string in the output array.
Signature
static String[] returnMismatched(String str1, String str2)
Input
str1: a string
str2: a string
Note: You can only expect valid english letters (a-z; A-Z) and spaces.
Output
An array containing all words that do not match between str1 and str2.
Examples
str1: "Firstly this is the first string"
str2: "Next is the second string"
output: ["Firstly", "this", "first", "Next", "second"]
str1: ""
str2: ""
output: []
str1: ""
str2: "This is the second string"
output: ["This","is","the","second","string"]
str1: "This is the first string"
str2: "This is the second string"
output: ["first", "second"]
str1: "This is the first string extra"
str2: "This is the second string"
output: ["first", "extra", "second"]
str1: "This is the first text"
str2: "This is the second string"
output: ["first", "text", "second", "string"]