Problem statement

https://binarysearch.com/problems/Coprime-Suspects/

Solution

Number of steps will be always 0, 1 or 2, because we can make numbers even.

Complexity

It is O(1) for time and space.

Code

class Solution:
    def solve(self, a, b):
        if gcd(a, b) != 1: return 0
        if gcd(a, b-1) != 1 or gcd(a, b+1) != 1 or gcd(a-1, b) != 1 or gcd(a+1, b) != 1: return 1
        return 2