← Unit 1 · all exercises
Saved in this browser only

Distance from zero

Return the value without its sign: 5 stays 5, and -5 becomes 5.

int size(int n)

Solution.java
Loading editor…
Results

Examples

  • size(5) → 5
  • size(-5) → 5

There are also 3 hidden tests you can't see. Solve the problem, not the examples.