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

Stats:

CreatedFeb 2, 2018
Warriors Trained31
Total Skips0
Total Code Submissions21
Total Times Completed6
Ruby Completions6
Total Stars0
% of votes with a positive feedback rating50% of 4
Total "Very Satisfied" Votes0
Total "Somewhat Satisfied" Votes4
Total "Not Satisfied" Votes0
Total Rank Assessments5
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • TiSer Avatar
Ad