Skip to content

No need to check for abs(num) again which increases the TC #8

@Sivaramjallu001

Description

@Sivaramjallu001

class Solution:
def findClosestNumber(self, nums: List[int]) -> int:
min_distance = float("inf")
res = None
for num in nums:
distance = abs(num)
if distance < min_distance or (distance == min_distance and num > res):
min_distance = distance
# res = num
return res

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions