Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def decode(self, encoded: List[int], first: int) -> List[int]:
- # Initialise arr with first
- arr = [first] * (len(encoded) + 1)
- # Loop through encoded
- # Use encoded[0] and first to generate arr[1]
- # Use encoded[1] and arr[1] to generate arr[2]
- # ...
- for i in range(len(encoded)):
- # Put next_arr_num in i+1th index in arr
- arr[i+1] = encoded[i] ^ arr[i]
- # Return arr
- return arr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement