Skip to content

Practice Find Closest Number to Zero

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2239
LeetCode Problem

Find Closest Number to Zero

Problem Statement

Given an integer array nums of size n, return the number with the value closest to 0 in nums. If there are multiple answers, return the number with the largest value.

Source: Find Closest Number to Zero on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [-4,-2,1,4,8]
Output
1

# Example 2

Input
nums = [2,-1,1]
Output
1

Constraints

1 <= n <= 1000
-10^5 <= nums[i] <= 10^5

Related LeetCode Problems

Practice more problems similar to Find Closest Number to Zero.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.