Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6560 |

@blackshadows | 6400 |

@mb1973 | 5777 |

@Quandray | 5275 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 5074 |

@kirtidee18 | 4398 |

@sanjay05 | 3762 |

@mantu_singh | 3654 |

@gfgaccount | 3601 |

@marius_valentin_dragoi | 3525 |

Complete Leaderboard | |

Handle | Score |

@anish5256 | 991 |

@vimleshpratapsingh321 | 980 |

@skj7 | 899 |

@akhileshkumar562002 | 862 |

@kanewilliamson123 | 854 |

@pradeeppatidar1999 | 852 |

@pd420786 | 813 |

@infilooop | 800 |

@bunnybug320 | 796 |

@smitabose7826 | 784 |

@wallflowe101 | 778 |

Complete Leaderboard |

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 ≤ 10^{5}

1 ≤ A[i] ≤ 10^{7}

Login to report an issue on this page.

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

YesLoading...

The Inverting Factor

...