Finding the value closest to 0
Suppose you are given a list of
Q 1D points. Write code to return the value in
Q that is the closest to value
j. If two values are equally close to
j, return the smaller value.
Q = [1, -1, -5, 2, 4, -2, 1] j = 3 #Output: 2
Subscribe to premium account to see the solution.Get premium now