Can You Finish the Teleporter Board?
Updated
Problem statement
A board has squares numbered from 0 through end. You start on square start. Each turn you roll a die, and you may take as many turns as you like. Decide whether some series of die rolls can bring you to the last square, end.
The die has die sides. teleporters is a list of strings shaped like source,destination. Landing on a teleporter's source square moves you to its destination square.
- A roll can be any integer from
1throughdie, and you move forward that many squares. If the move would go pastend, you stop onend. - When you land on a teleporter source, you move to its destination, once for that turn. If the destination is also a teleporter source, you do not take that second teleporter.
- The square you start on does not trigger a teleporter. If
start == end, you are already on the last square. - Every teleporter is valid. No two teleporters share a source square, and the last square is never a source.
Return true if you can reach the last square and false otherwise.
Function
finishable(teleporters: String[], die: int, start: int, end: int) → booleanExamples
Example 1
teleporters = ["10,8","11,5","12,7","13,9"]die = 4start = 0end = 20return = falseThe die has four sides, so any roll that moves past square nine lands on square ten, eleven, twelve or thirteen. Each of those is a teleporter that sends you back to a lower square. You can never get past square thirteen, so the answer is false.
Example 2
teleporters = ["10,8","11,5","12,7","13,9","2,15"]die = 4start = 0end = 20return = trueThe new teleporter on square two sends you to square fifteen. From there, roll a one to reach sixteen, then roll a four to reach twenty, the last square. The answer is true.
Example 3
teleporters = ["10,8","11,5","12,7","13,9","2,15"]die = 4start = 9end = 20return = falseYou start on square nine. Any roll that moves past square nine lands on square ten, eleven, twelve or thirteen, and each one sends you back to a square from five through nine. You never get back down to the teleporter on square two, and you never get past thirteen. The answer is false.
Example 4
teleporters = ["10,8","11,5","12,1","13,9","2,15"]die = 4start = 9end = 20return = trueYou start on square nine again, but now the teleporter on square twelve goes to square one. Roll a three to land on twelve and jump to square one. Roll a one to land on square two, which sends you to fifteen. Then roll a one to sixteen and a four to twenty. The answer is true.
Example 5
teleporters = ["2,4","9,8","11,7","12,6","18,14","19,16","20,9","21,14","22,6","23,26","25,10","28,19","29,27","31,29","38,33","39,17","41,30","42,28","45,44","46,36"]die = 4start = 0end = 50return = falseWith a four-sided die, the farthest square you can stand on is seventeen. To move past it, a roll must land on square eighteen, nineteen, twenty or twenty-one. All four are teleporters that send you back to lower squares, so you never reach square fifty. The answer is false.
Example 6
teleporters = ["2,4","9,8","11,7","12,6","18,14","19,16","20,9","21,14","22,6","23,26","25,10","28,19","29,27","31,29","38,33","39,17","41,30","42,28","45,44","46,36"]die = 6start = 0end = 50return = trueWith a six-sided die you can reach square seventeen, then roll a six to land on twenty-three. That teleporter sends you up to twenty-six. From there, rolls carry you through squares thirty, thirty-four, forty and forty-four to fifty. The answer is true.
Example 7
teleporters = ["4,21","11,18","13,17","16,17","18,21","22,11","26,25","27,9","31,38","32,43","34,19","35,19","36,39","38,25","41,31"]die = 4start = 0end = 50return = trueRoll a four from square zero to land on square four, which sends you to twenty-one. Roll a three, then a four, to reach twenty-eight. Another four lands on thirty-two, which sends you to forty-three. A three and a four then take you to forty-six and fifty. The answer is true.
Example 8
teleporters = ["4,21","11,18","13,17","16,17","18,21","22,11","26,25","27,9","31,38","32,43","34,19","35,19","36,39","38,25","41,31"]die = 2start = 0end = 50return = falseWith a two-sided die, each roll moves only one or two squares. The farthest you can stand is square twenty-five. From there, every roll lands on square twenty-six or twenty-seven, and those send you back to twenty-five and nine. You can never get past them, so the answer is false.
Constraints
1 <= end <= 1000and0 <= start <= end.1 <= die <= end + 1.0 <= teleporters.length <= end.- Each teleporter's source is in
[0,end-1], and its destination is in[0,end]. - Each teleporter string holds two decimal integers separated by one comma, with no spaces.
More Atlassian Phone Screen questions
- Merge Overlapping IntervalsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Tennis Court SchedulingPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Implement a Rate LimiterPHONE SCREEN · Seen Oct 2026
- Longest Consistent Activity StreakPHONE SCREEN · Seen Sep 2026
- Music Player Operation SequencePHONE SCREEN · Seen Sep 2026
- Underline Shortest Unique SubstringsPHONE SCREEN · Seen Aug 2026
- Can a Dictionary Word Be Formed from Note Letters?PHONE SCREEN · Seen Feb 2026
- Word Path Moving Only Right or DownPHONE SCREEN · Seen Feb 2026
- Ordered Badge Entry and Exit ViolationsPHONE SCREEN · Seen Aug 2025
- Two Sum with an Ordered Index PairPHONE SCREEN · Seen Aug 2025
Similar questions at other companies
- Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
- Shortest Pin Path Through TopicsPinterest · PHONE SCREENPinterest interview questions
- Word Chain Jumps in a GridGoogle · PHONE SCREENGoogle interview questions
- Currency Conversion RateAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Route Graph Reachability with a Broken LinkFigma · PHONE SCREENFigma interview questions
- Minimum Currency ConversionsEPAM · PHONE SCREENEPAM interview questions
- Finite Web CrawlerMongoDB · PHONE SCREEN · ONSITE INTERVIEWMongoDB interview questions
- Currency Conversion RateBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Clone a Connected GraphAbridge · PHONE SCREENAbridge interview questions
- Rule References: Validity and EligibilityPlaid · PHONE SCREENPlaid interview questions