Problem · Array
Unique Difference Pattern
Learn this problemProblem statement
You are given a list of strings containing only uppercase English letters.
All strings in the list have the same length.
For each string, calculate the difference between adjacent letters based on their alphabetical positions.
- For example,
'B' - 'A' = 1,'C' - 'A' = 2. - These differences form a difference pattern for the string.
- In the list, all strings except one share the same difference pattern.
Identify and return the string with the unique difference pattern.
Function
findUniqueDifferencePattern(series: String[]) → StringExamples
Example 1
series = ["ACB", "BDC", "CED", "DEF"]return = "DEF"Calculate the differences between adjacent letters:
"ACB":(C - A, B - C) = (+2, -1)"BDC":(D - B, C - D) = (+2, -1)"CED":(E - C, D - E) = (+2, -1)"DEF":(E - D, F - E) = (+1, +1)
The first three strings have the same difference pattern (+2, -1), while "DEF" has a different pattern (+1, +1).
Constraints
3 <= size of series[] <= 262 <= length of series[i] <= 26- All strings are uppercase English letters only.
- Within a test case, all strings are of equal length.
More Microsoft problems
- Maximum Pipeline ThroughputOA · Seen Jul 2026
- Maximum Strong Team SubarrayOA · Seen Jul 2026
- Minimum Cost K-Capable ModelsOA · Seen Jul 2026
- Alphabetically Smallest PalindromeOA · Seen Jul 2026
- Maximum Reward PointsOA · Seen Jul 2026
- Maximum Strength of Every NeuronOA · Seen Jul 2026
- Neural Network Subnetwork StrengthOA · Seen Jul 2026
- XOR MultiplicationOA · Seen Jul 2026