Leaderboard
Showing:
The Inverting Factor
Easy Accuracy: 49.75% Submissions: 219 Points: 2

Ishaan being curious as always was playing with numbers when he started to reverse the numbers. He invented something called the "inverting factor" of two numbers.
The inverting Factor of 2 integers is defined as the absolute difference between the reverse of the 2 integers.
Ishaan has an array A of N integers. He wants to find out the smallest possible Inverting Factor among all pairs of his integers. Help him find that.
Note : Trailing zeros in a number of ignored while reversing, i.e. 1200 becomes 21 when reversed.

 

Example 1:

​Input : arr[ ] = {56, 20, 47, 93, 45}
Output : 9
Explanation:
The minimum inverting factor is 9, of the pair (56,47)
Reverse 56 -> 65 and 47 -> 74
difference between them is 9.


​Example 2:

Input : arr[ ] = {48, 23, 100, 71, 56, 89} 
Output :  14 

 

Your Task:
This is a function problem. The input is already taken care of by the driver code. You only need to complete the function findMinimumInvertingFactor() that takes an array (arr), sizeOfArray (n), and return the smallest possible Inverting Factor among all pairs of his integers. The driver code takes care of the printing.

Expected Time Complexity: O(N*LOG(N)).
Expected Auxiliary Space: O(1).

 

Constraints : 
2 ≤ N ≤ 105
1 ≤ A[i] ≤ 107

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

The Inverting Factor

Output Window