A company wants all of its employees to focus on cyber security and hence regularly change their passwords. Given two binary string passwords s and t of equal length. Each string represents a binary integer where the first character represents the most significant bit of the number. You can rearrange the characters of t in any order you want.
The task is to maximize the value of bitwise XOR of s and t. Return this maximum possible XOR as a binary string of length the same as the input strings.
For example,
s = "0011110", t = "1111000",
It is optimal to rearrange the characters of t to "1100011".
The bitwise XOR of s and t would be "1111101".
Hence the answer is "1111101". It can be shown that this is the maximum possible answer.
Function Description
Complete the function getMaximumXor in the editor below. The function must return a binary string denoting the maximum possible value of bitwise XOR.
getMaximumXor has the following parameters:
s: a binary string
t: a binary string
Constraints
- 1 ≤ |s|, |t| ≤ 106, |s| denotes the length of string s.
- |s| = |t|
- It is guaranteed that s and t contain characters '0' and '1' only.
No comments:
Post a Comment