Loading...
Loading...
Loading...
An online coding contest uses negative marking, so a score can be below zero. The leaderboard shows the gap between two players: how many points apart they are, always as a number that is zero or more.
Read the two scores and print the gap, without using Math.abs.
Example 1
Input
3 10
Output
7
10 - 3 = 7.
Example 2
Input
6 -4
Output
10
From -4 up to 6 is 10 points.
Try the problem first. Open one hint at a time.
Subtract one score from the other. If the result is negative, flip its sign.
The gap can reach 2 × 10^9, which is more than an int can hold. Read the scores into long variables.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor