FastPrepFewest Dice Rolls to the Last Square
Problems/Fewest Dice Rolls to the Last Square

Fewest Dice Rolls to the Last Square

Rippling logoRippling● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Here you start on square 1 of a square board whose squares are numbered in a zigzag from the bottom left. Each move goes forward 1 to 6 squares, a square with a jump must be taken, and a move takes at most one jump. You return the fewest moves to the last square, or -1. The board format, limits and examples are our own.

The question list in this review puts snakes and ladders beside breadth-first search, and also names a tree question and token limiting. Its author, a San Francisco software engineer who received a Rippling offer, gives only a month for the date: January 2022. They rate the coding across the loop as medium difficulty. Three video interviews came after a recruiter call and an online coding test.

The review does not say which round asked it, and it gives no rules, input format or limits.

Our version is about 75% the same as the reported question.

A board game is played on an n x n grid board. The squares are numbered from 1 to n * n. Numbering starts at the bottom-left square (board[n - 1][0]) and goes left to right along the bottom row. The next row up goes right to left, the one after that left to right again, and so on, switching direction on every row.

If board[r][c] is not -1, the square at row r, column c has a jump: any player who lands there is moved to square board[r][c]. A jump can go forward (a ladder) or back (a snake).

Your token begins on square 1. In one move you roll a six-sided die and choose the result: from square x you go to any square from x + 1 to min(x + 6, n * n). If that square has a jump, you must take it. A move uses at most one jump: if the jump ends on another square with a jump, you stop there anyway.

Return the fewest moves needed to reach square n * n, or -1 if it cannot be reached.

Function

snakesAndLadders(board: int[][]) → int

Examples

Example 1

board = [[-1,-1,-1,-1],[-1,-1,-1,-1],[-1,2,-1,-1],[-1,-1,15,-1]]return = 2
board
01230-1-1-1-11-1-1-1-12-12-1-13-1-115-1

The squares are numbered 1 to 16, starting at the bottom left and changing direction on each row. From square 1, a roll of 2 lands on square 3, whose jump takes you to square 15. A roll of 1 then reaches square 16. That is 2 moves. One move is not enough: the highest square you can land on from 1 is 7, and square 7 sends you down to 2.

Example 2

board = [[1,-1,-1],[1,1,1],[-1,1,1]]return = -1
board
01201-1-111112-111

From square 1 you can land on squares 2 to 7, and every one of them sends you back to square 1. You can never get past square 1, so the answer is -1.

Example 3

board = [[-1,-1,-1,-1],[-1,16,-1,-1],[-1,-1,-1,-1],[-1,10,-1,-1]]return = 2
board
01230-1-1-1-11-116-1-12-1-1-1-13-110-1-1

A roll of 1 lands on square 2, which jumps you to square 10. The jump on square 10 is not used, because a move takes at most one jump. From square 10, a roll of 6 lands on square 16. That is 2 moves.

Constraints

  • n == board.length == board[i].length
  • 2 <= n <= 20
  • board[i][j] is -1 or a square number from 1 to n * n
  • Squares 1 and n * n have no jump (their value is -1).

More Rippling Onsite Interview questions

  • Filter, Sort, and Deduplicate Scheduled TasksPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Stateful Log Transform and SearchPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Camel CardsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Limit an Organization Tree's HeightPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Delivery Cost TrackerPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Maximum Currency Conversion Along a Simple PathPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Top K Frequent WordsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
  • Future-Effective Employee SalaryONSITE INTERVIEW · Seen Aug 2026
  • Filter and Sort Scheduled TasksONSITE INTERVIEW · Seen Jul 2026

Similar questions at other companies

  • Rotting OrangesSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Minimum Time to Spread Through a GridAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Minimum Time to Rot All OrangesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Number of Islands with Diagonal ConnectivityGoogle · ONSITE INTERVIEWGoogle interview questions
  • Island Count and Maximum AreaOracle · ONSITE INTERVIEWOracle interview questions
  • Shortest Increasing Path to a TargetUber · ONSITE INTERVIEWUber interview questions
  • Find and Reconstruct a Binary-Matrix PathMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Rotting OrangesOtter.ai · ONSITE INTERVIEWOtter.ai interview questions
  • Fuel-Aware Grid ReachabilityBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Maximum Number of Fish in a GridGlobalization Partners · ONSITE INTERVIEW

Interview reports that mention this question

  • Rippling No-Level Older Reports: 31 Experiences (Part 6 of 6)

Rippling interview experiences

  • Rippling No-Level Onsite Loops: 24 Experiences (Part 5 of 6)
  • Rippling No-Level Screens and Loops: 18 Experiences (Part 4 of 6)
  • Rippling No-Level Coding Screens: 37 Experiences (Part 3 of 6)
  • Rippling No-Level Design, Screens: 30 Experiences (Part 2 of 6)
  • Rippling SWE Interviews, No Level: 156 Experiences (Part 1 of 6)
All Rippling interview questionsSee Rippling hiring insights
Saved
class Solution {
    public int snakesAndLadders(int[][] board) {
        // Write your code here.
    }
}
Checking account…