Home Page » programming » Find the closest number
0 Votes
Vote Con!

Find the closest number

Arraysbinary search

Asked at:

Google

Given an array of sorted integers and find the closest value to the given number. Array may contain duplicate values and negative numbers.

Example : Array : 2,5,6,7,8,8,9
Target number : 5
Output : 5

Target number : 11
Output : 9

Target Number : 4
Output : 5

By preplr in programming · Asked 104 days 9 hours 14 mins ago

Questions: 2 Accepted: 0 ( 0% ) | Reputation: 2

 

Answers (0)

Your Answer

© Preply 2012. All rights reserved.