Problem · String
Odd One Out
Learn this problemProblem statement
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.'
Function
findOdd(series: String[]) → String
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
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
- Beautiful ArrangementONSITE INTERVIEW · Seen Jul 2026
- Find Minimum Cost to Remove Array ElementsONSITE INTERVIEW · Seen Jul 2026
- Group Shifted StringsONSITE INTERVIEW · Seen Jul 2026
- Longest Valid ParenthesesONSITE INTERVIEW · Seen Jul 2026
- Balancing TeamsOA · Seen Nov 2025
- Largest Sub-GridOA · Seen Nov 2025
- Discount TagsOA · Seen Oct 2024
- Alloy ProductionOA · Seen Sep 2024