6 kyu
Smallest Difference
222PostPunk
Description:
Given two arrays of integers, find the pair of values with the smallest difference and return that difference.
If both arrays are empty, return -1.
If one array is empty, return the smallest value from the non-empty array.
Note: Try to solve this without brute force.
Example:
arr1 = [1, 3, 5, 23, 5]
arr2 = [45, 34, 67, 2, 0]
Output = 1
Example empty array:
arr1 = [1, 3, 5, 23, 5]
arr2 = []
Output = 1
Example two empty arrays:
arr1 = []
arr2 = []
Output = -1
Arrays
Algorithms
Fundamentals
Similar Kata:
Stats:
Created | Dec 24, 2016 |
Published | Dec 24, 2016 |
Warriors Trained | 535 |
Total Skips | 8 |
Total Code Submissions | 989 |
Total Times Completed | 222 |
JavaScript Completions | 222 |
Total Stars | 20 |
% of votes with a positive feedback rating | 87% of 95 |
Total "Very Satisfied" Votes | 77 |
Total "Somewhat Satisfied" Votes | 12 |
Total "Not Satisfied" Votes | 6 |
Total Rank Assessments | 9 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |