top of page
  • seidetepervi

Find-closest-values-in-list-python

Assume this is a list: a = [5,6,6,7,1,2,10,15,7,6] and here another list b = [1.5,2.5] I want to get the closest value from a based on b: answer = …












find-closest-values-in-list-python


Given a sorted array, two integers k and x, find the k closest elements to x in the array. ... The value k is positive and will always be smaller than the length of the sorted array. ... For space complexity, it uses O(k) space for saving result list. 939c2ea5af





2 views0 comments

Recent Posts

See All
bottom of page