Skip to content

Commit 08d7d74

Browse files
Merge pull request #1613 from CodingTestStudy2/이진희
[이진희] Day28
2 parents d94bbc0 + a3e5446 commit 08d7d74

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
3+
1. 아이디어 : XOR 연산의 성질(A ^ B = C 이면 A ^ C = B)을 활용하여 복원
4+
5+
2. 시간복잡도 : O(N)
6+
7+
3. 자료구조/알고리즘 : 비트 연산 (XOR)
8+
9+
*/
10+
11+
class Solution {
12+
public int[] decode(int[] encoded, int first) {
13+
int[] arr = new int[encoded.length + 1];
14+
15+
arr[0] = first;
16+
17+
for (int i = 0; i < encoded.length; i++) {
18+
arr[i + 1] = encoded[i] ^ arr[i];
19+
}
20+
21+
return arr;
22+
}
23+
}

0 commit comments

Comments
 (0)