본문 바로가기
python-algorithm

Leetcode 1720. Decode XORed Array

by 무적김두칠 2021. 8. 31.

1
2
3
4
5
6
class Solution:
    def decode(self, encoded: List[int], first: int-> List[int]:
        ans=[first]
        for i in encoded:
            ans.append(i^ans[-1])
        return ans
cs

XOR -> Exclusive OR 문제구요
학부때 배웠던 Logical circuit 생각해보시면 쉽게 풀수있는데
파이썬에서는 " ^ " operator가 XOR 입니다.  아마 다른언어에서는 power의 개념으로 쓰이는 operator죠

반응형

댓글