Company: MongoDB
Difficulty: medium
We're building the game engine for Thrilling Teleporters, a board game with N+1 tiles, starting from tile 0. Certain tiles contain teleporters that instantly move the player to a specific tile, either forward or backward. For example, here are three teleporters: teleporters1 = [ "3,1", -- From tile 3 to tile 1 "4,2", -- From tile 4 to tile 2 "5,10" -- From tile 5 to tile 10 ] Or as seen on the board: "3,1" ┌─<───<─┐ N = 12 v │ 0 → 1 → 2 → 3 . 4 . 5 . 6 → 7 → 8 → 9 → 10 → 11 → 12 ^ │ │ ^ └─<───<─┘ └──>───>───>───>───>──┘ "4,2" "5,10" After rolling the die: The player moves forward by the number rolled. If the player lands on a tile with a teleporter, they are immediately sent to its destination. The player can’t move past the final tile N, and only one teleporter is used per die roll. To add variety, the die can have any number of sides (minimum 2). Write a function that returns all unique tiles the player can reach in a single die roll, given: A list of telep