Skip to content

Latest commit

 

History

History
19 lines (17 loc) · 468 Bytes

2451.md

File metadata and controls

19 lines (17 loc) · 468 Bytes

2451. Odd String Difference

Solution 1 (time O(n), space O(n))

class Solution(object):
    def oddString(self, words):
        """
        :type words: List[str]
        :rtype: str
        """
        d = collections.defaultdict(list)
        for s in words:
            d[tuple(ord(s[i]) - ord(s[i - 1]) for i in range(1, len(s)))].append(s)
        for v in d.values():
            if len(v) == 1:
                return v[0]
        return ""