ML Engineer MasterClass (April) | 6 seats left

Random Walk on a Number Line

Random Walk on a Number Line

Problem Statement

The Question

Interview question: A particle starts at integer position $k$ on the number line, where $0 < k < N$. At each step, it moves right to $k+1$ with probability $p$, or left to $k-1$ with probability $q = 1 - p$. The walk stops when the particle hits either $0$ or $N$. What is the probability it reaches $N$ before $0$? As a follow-up: what is the expected number of steps until th...

Unlock the full lesson

Created by interviewers from Google and Meta. Master every concept you need to land your dream role.

All courses — Data, ML/AI & Quant
Unlimited coding submissions
Hands-on projects with real datasets
Detailed solutions in text & video
Monthly content updates
Join Premium