Problem statement

https://binarysearch.com/problems/Robinhood/

Solution

Just do what is asked.

Complexity

It is O(t), where t is number of steps. It can be estimated as log(t/n).

Code

class Solution:
    def solve(self, n, e, o, t):
        p = [e, o]
        steps = 1
        while n < t:
            n *= (1 + p[0]/100)
            p = p[::-1]
            steps += 1
        return steps - 1