VOOZH about

URL: https://www.geeksforgeeks.org/dsa/count-pandigital-fractions-pairs-in-given-array/

⇱ Count Pandigital Fractions pairs in given Array - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Count Pandigital Fractions pairs in given Array

Last Updated : 15 Jul, 2025

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:
Explanation:
The fractions are 12345/67890, 12345/4567890, and 123/4567890 

Input: arr = [ 12345, 6789 ] 
Output:


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:

Output:
3

Time Complexity: O(N2
Auxiliary Space: O(1), As constant extra space is used.

Comment
Article Tags:
Article Tags: