[Sample Evaluation] Closest Element - UnSorted 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 unsorted integers, write a python program to find the closest list element to a given number.

Test Data

Input Data 1
121, 108, 120, 150, 145, 111, 150
144
Output Data 1
The closest element in the list [121, 108, 120, 150, 145, 111, 150] to the target number 144 is 145
Input Data 2
121, 101, 90, 99, 132, 111, 144
100
Output Data 2
The closest element in the list [121, 101, 90, 99, 132, 111, 144] to the target number 100 is 99

Comments

There are no comments at the moment.