Problem · String
Odd One Out
Analyze the difference in adjacent letters of the alphabet given a string. Given an input sequence of words, find the 'Odd One Out' by checking the difference between adjacent letters. The element having a distinct difference is the 'Odd One Out.'
Complete the function findOdd in the editor.
findOdd has the following parameter(s):
string series[n]: an array of strings
Returns
string: the odd one out.
Examples
01 · Example 1
series = ["ACB", "BDC", "CED", "DEF"] return = "DEF"
In the first three strings, the differences between the letters are (+2, -1), e.g. 'C' - 'A' = 2, 'B' - 'C' = -1. In the last string, the differences are (+1, +1). "DEF" is the odd one out.
Constraints
- 3 ≤ n ≤ 26
- 2 ≤ length of series[i] ≤ 26
- All strings are uppercase English letters only.
- Within a test case, all strings are of equal length.
More MathWorks problems
public String findOdd(String[] series) {
// write your code here
}
series["ACB", "BDC", "CED", "DEF"]
expected"DEF"
sign in to submit