https://leetcode.com/problems/integer-replacement/


Runtime: 415 ms, faster than 7.73% of Python3 online submissions for Integer Replacement.

Memory Usage: 14 MB, less than 75.31% of Python3 online submissions for Integer Replacement.


```python
class Solution:
    result = float("inf")
    def integerReplacement(self, n: int) -> int:
        #7:42
        result = float("inf")
        def trace(number, steps):
            if number == 1:
                if steps < self.result:
                    self.result = steps
                return
            if number < 1:
                return
            if number % 2 == 0:
                trace(number/2, steps+1)
            else:
                trace(number + 1, steps+1)
                trace(number - 1, steps+1)
        trace(n, 0)
        return self.result
        #7:46
```
