Closest Key
Start Timer
0:00:00
Given a dictionary with keys of letters and values of a list of letters, write a function closest_key
to find the key with the input value closest to the beginning of the list.
Example:
Input:
dictionary = {
'a' : ['b','c','e'],
'm' : ['c','e'],
}
input = 'c'
Output:
closest_key(dictionary, input) -> 'm'
is at distance 1 from and 0 from . Hence closest key for is .
Recommended questions for you
Personalized based on your user activity, skill level, and preferences.
.
.
.
.
.
.
.
.
.
Comments