One-Roll Teleporter Landings
Updated
Problem statement
A board contains integer squares from 1 through end. You begin at start and roll a die with faces 1 through sides exactly once.
If the rolled landing square is the source of a teleporter, move once to its destination. Do not activate another teleporter during the same roll. Discard rolls whose initial landing square is greater than end. Return all distinct final positions in increasing order.
Function
oneRollLandings(start: int, end: int, sides: int, teleporters: int[][]) → int[]Examples
Example 1
start = 2end = 10sides = 4teleporters = [[3,9],[5,1]]return = [1,4,6,9]The four initial landings are 3, 4, 5, and 6. Teleporters change 3 to 9 and 5 to 1.
Example 2
start = 8end = 10sides = 4teleporters = [[9,10],[10,10]]return = [10]Only initial landings 9 and 10 remain on the board, and both finish at 10.
Constraints
1 <= start <= end <= 10^5.1 <= sides <= 10^5.- Teleporter sources are unique, and every endpoint is in
[1, end].
More Splunk Phone Screen questions
Similar questions at other companies
- Count Distinct Underwriting PII ValuesAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
- Bounded IPv4 FilterAmazon · PHONE SCREEN
- SimpleRDD Multiset IntersectionDatologyAI · PHONE SCREEN
- Vehicle Maintenance Event ReadinessWaymo · PHONE SCREENWaymo interview questions
- Summarize the Latest Event for Each DeviceOneTrust · PHONE SCREEN
- Project JSON Fields into a Target FormatBooking.com · PHONE SCREEN
- Employee Training StatusVanta · PHONE SCREEN
- Select Object by Key ExtremeBridge · PHONE SCREENBridge interview questions
- Group Names by DepartmentMastercard · PHONE SCREENMastercard interview questions
- Badge Records Without a MatchWhatNot · PHONE SCREENWhatNot interview questions