The Odd String Difference problem gives you a list of strings of equal length. For each string, compute the "difference array" — the array of consecutive character differences. Exactly one string will have a different difference array from all others. Find and return that odd-one-out string. This easy coding problem tests difference array computation with hash map grouping.
Visa, Datadog, and IBM ask this to test string difference array computation and quick grouping. A string's identity is captured by its difference array (the gaps between consecutive characters). Group strings by this canonical representation and find the group of size 1. The array, hash table, and string interview pattern is demonstrated.
Difference array encoding + hash map grouping. For each string s, compute diff = tuple(ord(s[i+1]) - ord(s[i]) for i in range(len(s)-1)). Build a frequency map of these tuples. The string whose diff tuple appears exactly once is the answer.
words=["adc","wzy","abc"]. Length=3.
Difference array encoding uniquely identifies a string's "shape" regardless of starting character. Strings with the same difference array are shifts of each other (same relative character gaps). This encoding appears in music transposition, cipher detection, and string canonicalization. Practice grouping strings by their canonical representation (difference array, sorted characters, character frequency vector).