Skip to content

Commit

Permalink
chore: day 21
Browse files Browse the repository at this point in the history
  • Loading branch information
shiwangi-07 committed Apr 15, 2024
1 parent ac8845f commit bd9a95d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Medium/Day 21/problem.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Your are given two array a and b, each of length n, consisting of non-negative integers.
The i-th elements of a and b are ai and bi, respectively.
A non-negative integer x is said to be good when the following condition is satisfied:
If it is possible to permute b so that ai XOR bi = x holds for every integer i such that 1 ≤ i ≤ n,
where XOR is the bitwise XOR.
Print all good integers in ascending order.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------

Input:
First line of input contains one integer n(1 <= n <= 2000) - size of the array.
Second line of input contains n integers - array a.
Third line of input contains n integers - array b.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------

Output:
Print all the good integers in ascending order.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------

Time Limit: 2 sec
Memory Limit: 1024 MB
21 changes: 21 additions & 0 deletions Medium/Day 21/sample_tc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Sample Input 1:
3
1 2 3
6 4 7

Sample Output 1:
1
5

If we permute b into (4,7,6), we have a1 XOR b1 = a2 XOR b2 = a3 XOR b3 = 5, so 5 is a good integer.
There are no other good integers.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------

Sample Input 2:
2
0 1
0 2

Sample Output 2:
0
1 change: 1 addition & 0 deletions Medium/Day 21/solution.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Write your code here.

0 comments on commit bd9a95d

Please sign in to comment.