All problems
Two State Expected Hitting Time
Problem
In the chain [[1 - a, a], [b, 1 - b]] with a > 0, the expected number of steps to reach state 1 from state 0 is 1 / a.
Given a, return the expected hitting time.
Hint
Condition on the first step and solve the one-step recurrence.
Test cases
case 1
in: [0.5]
expected: 2
case 2
in: [0.1]
expected: 10
case 3
in: [1]
expected: 1
Starter codePython
def two_state_expected_hitting_time(a):
# Your code here
pass3 test cases · run your code against them in the editor