Ad
Fundamentals
Code
Diff
  • def TempCloseTo0(arr):
        if not arr: return 0
        return min(arr, key=lambda x: (abs(x), -x))
    • def TempCloseTo0(arr):
    • if len(arr)==0: return 0
    • else :
    • j=max(arr)
    • for i in arr:
    • if abs(i)<j :
    • j=abs(i)
    • return j
    • if not arr: return 0
    • return min(arr, key=lambda x: (abs(x), -x))