FastPrepKnight Survival Probability
Problems/Knight Survival Probability

Knight Survival Probability

Expedia logoExpedia● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report gives a zero-indexed square board, the same kind of knight moves for every square, and a probability printed to six decimals. We chose the limits and the interface that returns a double. Our version is about 99% the same as the reported question.

A knight starts at (row,column) on a size by size board, indexed from 0. At each step it independently chooses one of all eight knight displacements with probability 1/8: move two cells along one axis and one along the other.

Return the probability that it stays on the board throughout exactly moves steps. A move off the board ends that path; do not renormalize among legal moves. Zero moves has probability 1.

Answers are accepted within an absolute tolerance of 0.000001, matching the source six-decimal output precision.

Function

knightSurvival(size: int, moves: int, row: int, column: int) → double

Examples

Example 1

size = 3moves = 2row = 0column = 0return = 0.0625

From a corner of the 3x3 board, two of eight moves survive each step. The probability is (2/8)^2=0.0625.

Example 2

size = 1moves = 0row = 0column = 0return = 1.0

No move is made, so the knight remains at its valid starting cell.

Constraints

  • 1 <= size <= 25.
  • 0 <= moves <= 100.
  • 0 <= row, column <= 24.
  • Both starting coordinates are smaller than size.

More Expedia Online Assessment questions

  • Balanced NumbersOA · Seen Aug 2026
  • REST API: Discounted PriceOA · Seen Aug 2026
  • Maximum Team SizeOA · Seen Mar 2026
  • Per-Domain Request LimiterOA · Seen Oct 2025
  • Count Equal-Frequency SubsequencesOA · Seen Mar 2025
  • Count Increasing Stock PeriodsOA · Seen Mar 2025
  • Get Minimum StepsOA · Seen Oct 2024
  • Rank Songs by PopularityOA · Seen Oct 2024
  • Calculate the SumOA · Seen Oct 2024
  • Get Maximum EfficiencyOA · Seen Oct 2024

Similar questions at other companies

  • Frog Paths Without Long RunsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Count Lucky TicketsThe D.E. Shaw Group · OAThe D.E. Shaw Group interview questions
  • Maximum Score with Prime JumpsMicrosoft · OAMicrosoft interview questions
  • Jump Game with Prime-Step RuleUber · OAUber interview questions
  • Count Shipment SchedulesMorgan Stanley · OAMorgan Stanley interview questions
  • Unique Paths Through a GridPeopleStrong · OAPeopleStrong interview questions
  • Get Minimum OperationsJP Morgan Chase · OAJP Morgan Chase interview questions
  • Jump Game with Prime-3 StepsAgoda · OAAgoda interview questions
  • Find Encrypted NumberAmazon · OA
  • Prime StringSnowflake · OASnowflake interview questions

Interview reports that mention this question

  • Expedia New Grad SDE Interviews: 20 Experiences (Part 1 of 3)

Expedia interview experiences

  • Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
  • Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
  • Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
  • Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
  • Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)
All Expedia interview questionsSee Expedia hiring insights
Saved
class Solution {
    public double knightSurvival(int size, int moves, int row, int column) {
        // Write your code here.
    }

}
Checking account…