Retired

In unsorted array of integers, return the pair with the sum closest to N (retired)

24 of 25milesburton

Description:

This is a fairly popular interview question from Programmer Pearls.

The aim of the question is to return a pair of numbers which is as close to the target number as possible.

# array: [9,-3, -10, -4, -5], target: 4 ==  [9, -5]
# array: [1, -1, -2,-4], target: 0 == [1,-1]
# array: [0, 2, -10, 10, 5, 4], target: 0 == [-10, 10]
Algorithms
Interview Questions

Stats:

CreatedOct 7, 2013
Warriors Trained100
Total Skips16
Total Code Submissions81
Total Times Completed25
CoffeeScript Completions24
Total Stars1
% of votes with a positive feedback rating35% of 10
Total "Very Satisfied" Votes3
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes5
Total Rank Assessments14
Average Assessed Rank
5 kyu
Highest Assessed Rank
3 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • milesburton Avatar
  • jhoffner Avatar
Ad