Skip to content

Practice Odd String Difference

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2451
LeetCode Problem

Odd String Difference

Problem Statement

You are given an array of equal-length strings words. Assume that the length of each string is n. Each string words[i] can be converted into a difference integer array difference[i] of length n - 1 where difference[i][j] = words[i][j+1] - words[i][j] where 0 <= j <= n - 2. Note that the difference between two letters is the difference between their positions in the alphabet i.e. the position of 'a' is 0, 'b' is 1, and 'z' is 25. All the strings in words have the same difference integer array, except one. You should find that string. Return the string in words that has different difference integer array.

Source: Odd String Difference on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
words = ["adc","wzy","abc"]
Output
"abc"

# Example 2

Input
words = ["aaa","bob","ccc","ddd"]
Output
"bob"

Constraints

3 <= words.length <= 100
n == words[i].length
2 <= n <= 20
words[i] consists of lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Odd String Difference.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.