FastPrepEscape the Haunted Castle
Problems/Escape the Haunted Castle

Escape the Haunted Castle

Persona logoPersona● EasyFULLTIMENEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A firsthand Persona online assessment report keeps the full prompt of Escape the Haunted Castle Pt 1, the class model, the 10 by 10 grid limit, the up, down, left, and right movement, the unreachable result, and the sample. The story and the sample need one number as the distance. The photographed starter comment wrongly says the return is an integer array. So our version follows the story and the sample, which agree. Our version is about 97% the same as the reported question.

An adventurer starts at (0, 0) in a rows × columns haunted castle. Walls are impassable, and the adventurer may move one cell up, down, left, or right.

Return the minimum number of moves needed to reach escapePoint, or -1 when no path exists.

Function

escapeCastle(rows: int, columns: int, walls: int[][], escapePoint: int[]) → int

Examples

Example 1

rows = 2columns = 2walls = [[0,1]]escapePoint = [1,1]return = 2

The only route moves down and then right.

Example 2

rows = 3columns = 3walls = [[1,0],[1,1],[1,2]]escapePoint = [2,2]return = -1

A complete wall row separates the start from the exit.

Example 3

rows = 1columns = 1walls = []escapePoint = [0,0]return = 0

The adventurer starts on the escape point.

Constraints

  • 1 <= rows, columns <= 10.
  • Every wall and the escape point are distinct valid cells.
  • (0, 0) is not a wall.

Source note: This gallery includes the original prompt materials and an additional new-grad report of the same assessment question.

More Persona Online Assessment questions

  • Rank Football TeamsOA · Seen Oct 2026
  • Escape the Haunted Castle with TreasuresOA · Seen Oct 2024
  • File Download Coverage PercentageOA · Seen Sep 2023
  • Treasure HunterOA · Seen May 2022

Similar questions at other companies

  • Safest Shortest Path Through a GridSnowflake · OASnowflake interview questions
  • Minimum MovesHarness · OA
  • Competitive ForagingAkuna Capital · OAAkuna Capital interview questions
  • Shortest Path Around Rectangular ObstaclesDRW · OADRW interview questions
  • Drone Delivery with Battery Swap StationsCisco · OACisco interview questions
  • Minimum Knight MovesMcKinsey & Company · OAMcKinsey & Company interview questions
  • Minimum MovesGoldman Sachs · OAGoldman Sachs interview questions
  • Grid ExplorationIMC Trading · OAIMC Trading interview questions
  • Shortest Travel Time in a Grid with Traffic LightsWaymo · PHONE SCREENWaymo interview questions
  • Fire Station Response BillLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
All Persona interview questionsSee Persona hiring insights
Saved
class Solution {
    public int escapeCastle(int rows, int columns, int[][] walls, int[] escapePoint) {
        // Return the shortest escape distance.
    }
}
Checking account…