PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates understanding of probability theory and stochastic processes, focusing on win probability in an alternating coin-toss game and reasoning about pattern occurrence and stopping times in random sequences.

  • easy
  • Morgan Stanley
  • Coding & Algorithms
  • Data Scientist

Compute win probability in coin-toss game

Company: Morgan Stanley

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

Two players, A and B, play the following game with a fair coin: - They toss the coin alternately: A tosses first, then B, then A, then B, and so on. - The sequence of results (H for heads, T for tails) is recorded in order. - The game ends as soon as the subsequence "HT" (a head immediately followed by a tail on the next toss) appears for the first time. - The person who tosses the **tail** in this first "HT" subsequence wins the game. Assuming the coin is fair and the game continues indefinitely until it ends, what is the probability that player A wins the game?

Quick Answer: This question evaluates understanding of probability theory and stochastic processes, focusing on win probability in an alternating coin-toss game and reasoning about pattern occurrence and stopping times in random sequences.

Return the exact probability that player A wins the alternating fair-coin game that ends at the first HT pattern.

Constraints

  • Return the reduced probability as a string fraction.

Examples

Input: ()

Expected Output: '4/9'

Explanation: Solving the four-state recurrence for alternating tosses gives A win probability 4/9.

Hints

  1. Track whose turn it is and whether the previous toss was H.
  2. Solve the resulting linear equations.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Implement Factorial and Squares - Morgan Stanley (medium)
  • Compute maximum non-overlapping meetings - Morgan Stanley (medium)
  • How do you escape the circle? - Morgan Stanley (medium)
  • Compute minimal cost to merge numbers - Morgan Stanley (Medium)
  • Count decodings of a digit string - Morgan Stanley (Medium)