PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/SoFi

Implement chance of a personal best

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to perform simulation-based probabilistic estimation, sample and aggregate historical per-obstacle times, and correctly handle incomplete run records within a collection.

  • hard
  • SoFi
  • Coding & Algorithms
  • Software Engineer

Implement chance of a personal best

Company: SoFi

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

You are given a simplified model for tracking race times on an obstacle course. - A **course** has a fixed number of obstacles. - A **run** records the time spent on each obstacle in order. - A run may be **complete** or **incomplete**. - A **run collection** stores many runs for the same course. For an obstacle index `i`, the historical times available for that obstacle come from **all other runs that reached obstacle `i`**, including incomplete runs. Implement the method `chance_of_personal_best(run)` in `RunCollection`. ### Required behavior Given an **in-progress** run: 1. Perform **10,000 simulation trials**. 2. In each trial, for every obstacle not yet completed in the current run, randomly choose one historical time for that obstacle from the other runs in the collection that have a recorded time for that obstacle. 3. Combine the current run's existing obstacle times with the sampled remaining times. 4. Check whether the simulated total time is **less than or equal to** the current **personal best**. 5. Return the fraction of trials that are a personal best (or tie the personal best). ### Important details - The current personal best is the **minimum total time among completed runs only**. - When sampling future obstacle times, include times from incomplete historical runs **if they reached that obstacle**. - Do **not** sample from the in-progress run being evaluated. - The returned value should be a floating-point probability, and with 10,000 trials it should usually be within **0.02** of the true probability. ### Example Suppose a course has 3 obstacles and the historical runs are: - `[3, 3, 2]` - `[3, 3, 3]` The current in-progress run is `[3, 3]`. The personal best among completed runs is `8`. For the last obstacle, the historical times are `{2, 3}`. So the simulated completed run is either `[3,3,2]` or `[3,3,3]`, each with equal probability. Therefore the chance of matching or beating the personal best is about `0.5`. ### Starter structure Assume classes similar to the following already exist: - `Course(title, obstacle_count)` - `Run(course)` with fields: - `course` - `complete` - `obstacle_times` - `add_obstacle_time(t)` - `get_run_time()` - `RunCollection(course)` with field: - `runs` Write the `chance_of_personal_best` method for `RunCollection`.

Quick Answer: This question evaluates a candidate's ability to perform simulation-based probabilistic estimation, sample and aggregate historical per-obstacle times, and correctly handle incomplete run records within a collection.

Related Interview Questions

  • Find Smallest Common Row Value - SoFi (easy)
  • Format words into wrapped/justified lines - SoFi (medium)
  • Find the second most frequent tag - SoFi (medium)
  • Implement a multithreaded task executor with semaphores - SoFi (medium)
  • Solve Time-Window and Binary Swap Problems - SoFi (easy)
SoFi logo
SoFi
Jan 21, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
11
0

You are given a simplified model for tracking race times on an obstacle course.

  • A course has a fixed number of obstacles.
  • A run records the time spent on each obstacle in order.
  • A run may be complete or incomplete .
  • A run collection stores many runs for the same course.

For an obstacle index i, the historical times available for that obstacle come from all other runs that reached obstacle i, including incomplete runs.

Implement the method chance_of_personal_best(run) in RunCollection.

Required behavior

Given an in-progress run:

  1. Perform 10,000 simulation trials .
  2. In each trial, for every obstacle not yet completed in the current run, randomly choose one historical time for that obstacle from the other runs in the collection that have a recorded time for that obstacle.
  3. Combine the current run's existing obstacle times with the sampled remaining times.
  4. Check whether the simulated total time is less than or equal to the current personal best .
  5. Return the fraction of trials that are a personal best (or tie the personal best).

Important details

  • The current personal best is the minimum total time among completed runs only .
  • When sampling future obstacle times, include times from incomplete historical runs if they reached that obstacle .
  • Do not sample from the in-progress run being evaluated.
  • The returned value should be a floating-point probability, and with 10,000 trials it should usually be within 0.02 of the true probability.

Example

Suppose a course has 3 obstacles and the historical runs are:

  • [3, 3, 2]
  • [3, 3, 3]

The current in-progress run is [3, 3].

The personal best among completed runs is 8. For the last obstacle, the historical times are {2, 3}. So the simulated completed run is either [3,3,2] or [3,3,3], each with equal probability. Therefore the chance of matching or beating the personal best is about 0.5.

Starter structure

Assume classes similar to the following already exist:

  • Course(title, obstacle_count)
  • Run(course) with fields:
    • course
    • complete
    • obstacle_times
    • add_obstacle_time(t)
    • get_run_time()
  • RunCollection(course) with field:
    • runs

Write the chance_of_personal_best method for RunCollection.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More SoFi•More Software Engineer•SoFi Software Engineer•SoFi Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ 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.