Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Latest commit

 

History

History
executable file
·
22 lines (11 loc) · 666 Bytes

Smallest_Difference.md

File metadata and controls

executable file
·
22 lines (11 loc) · 666 Bytes

Smallest Difference

Problem Statement

Write a function that takes in two non-empty arrays of integers. The function should nd the pair of numbers (one from the rst array, one from the second array) whose absolute difference is closest to zero. The function should return an array containing these two numbers, with the number from the rst array in the rst position. Assume that there will only be one pair of numbers with the smallest difference. Sample input: [-1, 5, 10, 20, 28, 3], [26, 134, 135, 15, 17] Sample output: [28, 26]

Explanation

We can use a Stack here

Solution

Check this Python code.