Showing:
Handle Score
@Ibrahim Nash 6560
@mb1973 5777
@Quandray 5275
@akhayrutdinov 5111
@saiujwal13083 5074
@kirtidee18 4398
@sanjay05 3762
@mantu_singh 3654
@gfgaccount 3601
@marius_valentin_dragoi 3525
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 

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