Given two numbers A and B, find the minimum number of moves to make them equal - where every move takes one unit.
The answer would always be the absolute difference between their values.
There are two ways by which we can ensure that the two given numbers end up being equal.
Reduce the number which is greater to the small number.
Increase the number which is smaller to the greater number.
Since, the cost of increasing a number and decreasing a number is the same, we can decipher that irrespective of the choice we make, we’ll have to use | A - B | units to make the two numbers equal.
read a,b print abs(a-b)
Sub-task wise solutions
Using int data type in C/C++ would give 20 points.
Notice that the constraint is 1018, so long long int data type will be needed to hold values as large as the constraints.
Languages like Python can use the their integer data type for this range still.