Skip to content

Latest commit

 

History

History
11 lines (10 loc) · 352 Bytes

File metadata and controls

11 lines (10 loc) · 352 Bytes

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

Input : arr[] = {1, 2, 4, 5, 6, 6, 8, 9}
             Target number = 11
Output : 9
9 is closest to 11 in given array

Input :arr[] = {2, 5, 6, 7, 8, 8, 9}; 
       Target number = 4
Output : 5