Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- python zip_longest
- 파이썬 프로그래머스
- python 릿코드
- 파이썬 알고리즘
- 상가수익률계산기
- 파이썬알고리즘풀기
- 알고리즘풀이
- 파이썬알고리즘
- leetcode 풀기
- 잇츠디모
- python priority queue
- 코틀린기초
- 파이썬 릿코드
- 파이썬릿코드
- 릿코드풀기
- python sorted
- 릿코드풀이
- 파이썬릿코드풀기
- 알고리즘풀기
- 파이썬 알고리즘 풀기
- leetcode풀기
- python 알고리즘
- 릿코드
- python xor
- 릿코드 파이썬
- leetcode풀이
- python Leetcode
- 릿코드 풀기
- binary search
- LeetCode
Archives
- Today
- Total
소프트웨어에 대한 모든 것
LeetCode 풀기 - 1720. Decode XORed Array 본문
반응형
1720. Decode XORed Array
https://leetcode.com/problems/decode-xored-array/
Decode XORed Array - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
문제)

솔루션1)
XOR은 교환법칙 결합법칙이 성립한다.
1 ^ x = 1, 좌변의 1을 제거하기 위해서 양변에 1^을 취한다
1 ^ 1 ^ x = 1 ^ 1,
0 ^ x = 0,
x = 0
위 과정을 반복한다.

class Solution:
def decode(self, encoded: List[int], first: int) -> List[int]:
ret = [first]
for e in encoded:
ret.append(ret[-1] ^ e)
return ret
반응형
'알고리즘 > LeetCode' 카테고리의 다른 글
LeetCode 풀기 - 1877. Minimize Maximum Pair Sum in Array (0) | 2021.11.06 |
---|---|
LeetCode 풀기 - 1281. Subtract the Product and Sum of Digits of an Integer (0) | 2021.11.06 |
LeetCode 풀기 - 1221. Split a String in Balanced Strings (0) | 2021.11.06 |
LeetCode 풀기 - 1302. Deepest Leaves Sum (0) | 2021.11.06 |
LeetCode 풀기 - 1979. Find Greatest Common Divisor of Array (0) | 2021.11.06 |