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.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Given a number N in decimal base, find number of its digits in any base (base b)
- Find the Nth digit from right in base B of the given number in Decimal base
- Given a number N in decimal base, find the sum of digits in any base B
- Pandigital Product
- C++ program to find all numbers less than n, which are palindromic in base 10 and base 2.
- Add two integers of different base and represent sum in smaller base of the two
- Complement of a number with any base b
- Check if a N base number is Even or Odd
- Number System and Base Conversions
- Largest value of x such that axx is N-digit number of base b
- Largest N digit number in Base B
- Find most significant bit of a number X in base Y
- Check if a number N starts with 1 in b-base
- Check whether a number has consecutive 0's in the given base or not
- 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
- Ternary number system or Base 3 numbers
- Check if a given number can be represented in given a no. of digits in any base
- Find the length of factorial of a number in any given base
- Count of primes after converting given binary number in base between L to R