Minimize Difference Between Two Numbers
Problem Overview
- Given two equal-length digit strings, find the minimum swaps of corresponding positions to make their integers as close as possible (minimize absolute difference).
- Input: S and T (length N up to 100,000), digits only, no leading zeroes; Output: minimum swaps required.
- Domain: very large integers handled as strings, allowing only position-wise swaps between the two numbers.
- From Microsoft interviews; a coding interview problem and common interview question on optimizing swaps.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
