일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 화상영어
- Writing
- Problem Solving
- 매일
- 10분
- 영어원서읽기
- FIT XR
- English
- 프로젝트
- Daily Challenge
- 만화도
- 쓰릴오브파이트
- 잡생각
- 개발자
- 운동
- 월간
- 미드시청
- 읽기
- 리얼 클래스
- leetcode
- 3줄정리
- 사이드
- 30분
- realclass
- 괜찮음
- 파비최
- 링피트
- 영어공부
- 스탭퍼
- 뭐든
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.11.01 Today's Challenge 본문
https://leetcode.com/problems/find-the-original-array-of-prefix-xor/
Find The Original Array of Prefix Xor - LeetCode
Can you solve this real interview question? Find The Original Array of Prefix Xor - You are given an integer array pref of size n. Find and return the array arr of size n that satisfies: * pref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i]. Note that ^ denotes the b
leetcode.com
XOR 연산을 하면 됨.
최적화를 위해 뒤에서 붙어 수행
class Solution:
def findArray(self, pref: List[int]) -> List[int]:
for i in range(len(pref)-1, 0, -1):
pref[i] = pref[i] ^ pref[i-1]
return pref
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
2023.11.03 Today's Challenge (0) | 2023.11.03 |
---|---|
2023.11.02 Today's Challenge (0) | 2023.11.02 |
2023.10.31 Today's Challenge (0) | 2023.10.31 |
2023.10.30 Today's Challenge (0) | 2023.10.30 |
2023.10.29 Today's Challenge (0) | 2023.10.29 |
Comments