[Sample Evaluation] Closest Element - Sorted List


Submit solution

Points: 10
Time limit: 0.2s
Memory limit: 10M

Author:
Problem type
Allowed languages
Python

Closest Element in Sorted List

Given a list of sorted integers, write a python program to find the closest list element to a given number.

Test Data

Input Data 1
1, 2, 4, 5, 6, 6, 8, 9
11
Output Data 1
The closest element in the list [1, 2, 4, 5, 6, 6, 8, 9] to the target number 11 is 9
Input Data 2
2, 5, 6, 7, 8, 8, 9
4
Output Data 2
The closest element in the list [2, 5, 6, 7, 8, 8, 9] to the target number 4 is 5

Comments

There are no comments at the moment.