Skip to content
Snippets Groups Projects
Name Last commit Last update
src
target
README.md
pom.xml

Resolution in Java language of the Closest to Zero exercise.

Requirements: Closest to zero Write a function “closestToZero” described by the following specifications:

given an array of positive and negative integers, it returns the closest number to zero if the closest number in input could be either negative or positive, the function returns the positive one if the input array is undefined or empty, the function returns 0

Examples:

when input is [8, 5, 10] it must returns 5 when input is [5, 4, -9, 6, -10, -1, 8] it must return -1 when input is [8, 2, 3, -2] it must return 2 when input is [2, 0], it must returns 0, as 0 is ... the closest number to 0