Given an array arr, the task is to count the pairs in the array such that arr[i]/arr[j] is a Pandigital Fraction.
A fraction N/D is called a Pandigital Fraction if the fraction contains all the digits from 0 to 9.
Input: arr = [ 12345, 67890, 123, 4567890 ]
The fractions are 12345/67890, 12345/4567890, and 123/4567890
Input: arr = [ 12345, 6789 ]
Approach: The idea is to iterate over every possible pair of the array using two nested loops and for every pair concatenate arr[i] and arr[j] into a single number and check if the concatenation of arr[i] and arr[j] is a Pandigital number in base 10 then increment count.
Below is the implementation of the above approach:
Time Complexity: O(N2)
Attention reader! Don’t stop learning now. Get hold of all the important mathematical concepts for competitive programming with the Essential Maths for CP Course at a student-friendly price. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.