Escape the Haunted Castle with Treasures
Problem statement
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.