Retired
Closest element in array (retired)
Description:
Given array of numbers. Find the closest element in array to given number in the most efficient way. Array can be ordered or not, numbers in array can be negative.
Example:
arr = [3,-2,13,4,12,15]
number = 8
Answer: "4"
PS: If there is two different closest numbers exists in array, it should return lower one.
Algorithms
Arrays
Data Types
Similar Kata:
Stats:
Created | Feb 2, 2018 |
Warriors Trained | 31 |
Total Skips | 0 |
Total Code Submissions | 21 |
Total Times Completed | 6 |
Ruby Completions | 6 |
Total Stars | 0 |
% of votes with a positive feedback rating | 50% of 4 |
Total "Very Satisfied" Votes | 0 |
Total "Somewhat Satisfied" Votes | 4 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 5 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 7 kyu |