# PROBLEM LINK:

Contest Division 1

Contest Division 2

Contest Division 3

Contest Division 4

Setter: Lavish Gupta

Testers: Felipe Mota, Abhinav sharma

Editorialist: Pratiyush Mishra

# DIFFICULTY:

639

# PREREQUISITES:

None

# PROBLEM:

Chef discovered that his secret recipe has been stolen. He immediately informs the police of the theft.

It is known that the policeman and thief move on the number line. You are given that:

The initial location of the policeman on the number line is **X** and his speed is **2** units per second.

The initial location of the thief on the number line is **Y** and his speed is **1** unit per second.

Find the minimum time (in seconds) in which the policeman can catch the thief. Note that, the policeman catches the thief as soon as their locations become equal.

# EXPLANATION:

As the relative speed with which the policeman chases the thief is **1** unit per second, the time needed would be equal to the distance between the positions of the two.

For each testcase the answer would be the absolute difference of the positions **X** and **Y**.

# TIME COMPLEXITY:

O(1) for each test case.

# SOLUTION:

Editorialist’s Solution

Setter’s Solution

Tester 1’s Solution

Tester 2’s Solution