Given an integer N. The task is to find the XOR and OR of all N digit palindromic numbers.
Output: XOR = 714 and OR = 1023
Output: XOR = 4606 and OR = 16383
- Find the starting and ending number of N-digit palindromic number by:
starting number = pow(10, n - 1) ending number = pow(10, n) - 1
- Iterate over starting number till ending number and check whether that number is palindromic or not.
- If the number is palindromic, then take XOR and OR of that number separately.
- Else proceed for next iteration and print the value of XOR and OR after all iterations.
Below is the implementation of the above approach:
XOR = 4606 OR = 16383
Time Complexity: O(10n)
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.
- Count all palindrome which is square of a palindrome
- Given a set, find XOR of the XOR's of all subsets.
- Find XOR of two number without using XOR operator
- Choose X such that (A xor X) + (B xor X) is minimized
- Count all pairs of adjacent nodes whose XOR is an odd number
- Check if the Xor of the frequency of all digits of a number N is zero or not
- Check if a number with even number of digits is palindrome or not
- Check if Sum and XOR of all elements of array is equal
- Maximum XOR value of maximum and second maximum element among all possible subarrays
- XOR and OR of all N-digit Armstrong numbers
- Find a number X such that (X XOR A) is minimum and the count of set bits in X and B are equal
- Number of subsets with same AND, OR and XOR values in an Array
- Find a number M < N such that difference between their XOR and AND is maximum
- Sum of all palindrome numbers present in an Array
- Find all palindrome numbers of given digits
- Sum of all N digit palindrome numbers
- Print all palindrome dates between the given years
- Sum of all Palindrome Numbers present in a Linked list
- Number whose XOR sum with given array is a given number k
- Find a number which give minimum sum when XOR with every number of array of integers
Improved By : AnkitRai01