FastPrepTreasure Hunter
Problems/Treasure Hunter

Treasure Hunter

Persona logoPersona● HardINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A firsthand Persona intern online assessment report keeps the full Treasure Hunter prompt and the bonus rules in three screenshots. You start with health 5. You want the fewest steps, then the most health. Movement goes up, down, left, and right. There are walls, digit traps, one optional treasure, traps that fire only once, and potions worth ten health. We set limits on the grid and on special cells, because the report gives no size cap. Our version is about 95% the same as the reported question.

You start at the top-left cell of a dungeon with 5 health. Move orthogonally through spaces. X is a wall, a digit is a trap that deals that much damage, H is a potion that restores 10 health, and T is the treasure.

A trap or potion applies only the first time that path enters its cell. Health must remain positive. Return [minimumSteps, maximumRemainingHealth], maximizing health only among minimum-step surviving paths. Return [-1, 5] when no path reaches a treasure.

Function

treasureHunter(dungeon: String[]) → int[]

Examples

Example 1

dungeon = [" X","2T"]return = [2,3]

The two-step path triggers damage 2 and reaches the treasure with health 3.

Example 2

dungeon = ["  H"," XX"," 9T"]return = [8,6]

The shortest surviving route first takes the potion, then survives the damage-9 trap with health 6.

Example 3

dungeon = [" X","XT"]return = [-1,5]

Walls isolate the treasure.

Constraints

  • 1 <= rows, columns <= 12.
  • The grid contains spaces, X, digits, H, and zero or one T.
  • The top-left cell is a space.
  • At most 15 trap and potion cells appear.

More Persona Online Assessment questions

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

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[] treasureHunter(String[] dungeon) {
        // Return {minimumSteps, maximumRemainingHealth}.
    }
}
Checking account…