Given an integer n and its base b. The task is to check if given number is Pandigital Number in the given base or not. A Pandigital number is an integer that has each digit of its base at least once.
It may be assumed that base is smaller than or equal to 36. In base 36, digits are [0, 1, …9. A, B, …Z]
Input : n = "9651723480", b = 10 Output : Yes Given number n has all digits from 0 to 9 Input : n = "23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", b = 36 Output : No Given number n doesn't have all digits in base 36. For example 1 is missing.
Make a boolean hash array of size equal to base of the number and initialize it with false. Now, iterate each digit of the number mark its corresponding index value as true in the hash array. In the end, check whether all the value in hash array are marked or not, if marked print “Yes” i.e Pandigital number else print “No”.
Below is the implementation of this approach:
This article is contributed by Anuj Chauhan. 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 write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Given a number N in decimal base, find number of its digits in any base (base b)
- C++ program to find all numbers less than n, which are palindromic in base 10 and base 2.
- Complement of a number with any base b
- Pandigital Product
- Check whether a number has consecutive 0's in the given base or not
- Check if a number N starts with 1 in b-base
- Number System and Base Conversions
- Number of trailing zeroes in base B representation of N!
- Check if the number is even or odd whose digits and base (radix) is given
- Check if a given number can be represented in given a no. of digits in any base
- Check if a number is power of k using base changing method
- Double Base Palindrome
- Write a program to add two numbers in base 14
- Program to find the last digit of X in base Y
- Convert from any base to decimal and vice versa