Given two binary strings A and B of equal lengths, the task is to print a string which is the XOR of Binary Strings A and B.
Input: A = “0001”, B = “0010”
Input: A = “1010”, B = “0101”
Approach: The idea is to iterate over both the string character by character and if the character mismatched then add “1” as the character in the answer string otherwise add “0” to the answer string to generate the XOR string.
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- XOR two binary strings of unequal lengths
- Find XOR of two number without using XOR operator
- Rearrange given binary strings to maximize their Bitwise XOR value
- Given a set, find XOR of the XOR's of all subsets.
- Choose X such that (A xor X) + (B xor X) is minimized
- Minimum flips in two binary arrays so that their XOR is equal to another array
- XOR of two numbers after making length of their binary representations equal
- XOR of path between any two nodes in a Binary Tree
- Pairs of complete strings in two sets of strings
- Meta Strings (Check if two strings can become same after a swap in one string)
- Number of common base strings for two strings
- Count of strings that become equal to one of the two strings after one removal
- Count of same length Strings that exists lexicographically in between two given Strings
- Check whether two strings can be made equal by reversing substring of equal length from both strings
- Program to add two binary strings
- Given two binary strings perform operation until B > 0 and print the result
- Count of distinct XORs formed by rearranging two Binary strings
- Ways to remove one element from a binary string so that XOR becomes zero
- Count of cyclic permutations having XOR with other binary string as 0
- Queries to find the maximum Xor value between X and the nodes of a given level of a perfect binary tree
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.