FastPrepEscape the Haunted Castle with Treasures
Problems/Escape the Haunted Castle with Treasures

Escape the Haunted Castle with Treasures

Persona logoPersona● HardFULLTIMENEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A firsthand Persona online assessment report keeps Escape the Haunted Castle Pt 2, including the grid with up, down, left, and right movement, treasures that can be taken once, the goal of fewest moves first and then most treasures, the unreachable pair, the Java signature, and the sample. The limit of 15 treasures is our choice, so the grading can use a bitmask. Our version is about 96% the same as the reported question.

An adventurer starts at (0, 0) in a haunted castle and moves orthogonally around walls. Treasure cells may be collected at most once.

Return [minimumMoves, maximumTreasures], where the second value is the greatest number of distinct treasures collectible on any minimum-move route to escapePoint. Return [-1, 0] when escape is impossible.

Function

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

Examples

Example 1

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

A four-step route across the top collects the treasure before reaching the exit.

Example 2

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

The start is sealed.

Example 3

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

Collecting a treasure would require extra moves, so no treasure belongs to a shortest route.

Constraints

  • 1 <= rows, columns <= 10.
  • 0 <= treasures.length <= 15.
  • Walls, treasure cells, and the escape point use valid coordinates; the start and exit are not walls.

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 CastleOA · Seen Oct 2024
  • File Download Coverage PercentageOA · Seen Sep 2023
  • Treasure HunterOA · Seen May 2022

Similar questions at other companies

  • Competitive ForagingAkuna Capital · OAAkuna Capital interview questions
  • Safest Shortest Path Through a GridSnowflake · OASnowflake interview questions
  • Drone Delivery with Battery Swap StationsCisco · OACisco interview questions
  • Minimum MovesHarness · OA
  • Shortest Path Around Rectangular ObstaclesDRW · OADRW 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 Grid Path with Obstacle EliminationsAmazon · ONSITE INTERVIEW
  • Shortest Grid Path with Obstacle EliminationGoogle · ONSITE INTERVIEWGoogle interview questions
All Persona interview questionsSee Persona hiring insights
Saved
class Solution {
    public int[] escapeCastleWithTreasures(int rows, int columns, int[][] walls, int[] escapePoint, int[][] treasures) {
        // Return {minimumMoves, maximumTreasures}.
    }
}
Checking account…