![]() |
VOOZH | about |
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.
Examples:
Input: arr = [ 12345, 67890, 123, 4567890 ]
Output: 3
Explanation:
The fractions are 12345/67890, 12345/4567890, and 123/4567890Input: arr = [ 12345, 6789 ]
Output: 0
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 the count.
Below is the implementation of the above approach:
3
Time Complexity: O(N2)
Auxiliary Space: O(1), As constant extra space is used.