Skip to content
LC-2433 Medium LeetCode

2433. Find The Original Array of Prefix Xor

Read the full problem statement on LeetCode.
Difficulty: medium Acceptance: 88% Topics: Array, Bit Manipulation
View full problem on LeetCode
Reference solution (spoiler · python)
# Time:  O(n)
# Space: O(1)

# array
class Solution(object):
    def findArray(self, pref):
        """
        :type pref: List[int]
        :rtype: List[int]
        """
        for i in reversed(xrange(1, len(pref))):
            pref[i] ^= pref[i-1]
        return pref

Solution from kamyu104/LeetCode-Solutions · MIT