Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Rabbit Grid Path Count

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Rabbit Grid Path Count. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

In a simplified Susquehanna International Group grid-navigation model, a rabbit starts at the top-left square of a rectangular grid and must reach the bottom-right square. On each move, it may move exactly one square right or one square down.

Implement count_paths(rows, cols) to return the number of distinct valid paths. Two paths are different if their sequences of moves differ.

Formal Specification

  • Input: Two integers, rows and cols, representing the number of grid rows and columns.
  • Output: An integer containing the number of paths from (0, 0) to (rows - 1, cols - 1).
  • The rabbit may not move up, left, or diagonally.
  • Use dynamic programming with at most O(cols) auxiliary space.

Constraints

  • 1 <= rows <= 1000
  • 1 <= cols <= 1000
  • The result must be returned exactly using Python integer arithmetic
  • Only right and down moves are allowed

Function Signature

def count_paths(rows, cols):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output