Skip to main content
Back to problems
Leetcode
Medium
Matrices
Combinatorics
Dynamic Programming
3988. Create Grid With Exactly K Paths I

Construct an m×nm \times n grid so that the number of valid paths from the top-left to the bottom-right is exactly kk.

Acceptance 0%
Problem Statement

Problem

You need to build a grid of size m×nm \times n such that the number of valid paths from the top-left cell to the bottom-right cell is exactly kk.

A path is formed by moving through the grid according to the rules given by the problem. Your task is to output one grid construction that satisfies the requirement whenever possible.

Because this is a construction problem, there may be many valid answers. Any grid that produces exactly kk paths is acceptable.

What you need to return

Return a valid grid representation meeting the required path count.

If no such grid can be constructed for the given parameters, return an empty result as defined by the platform.

Input Format

  • The input contains the grid dimensions and the target path count kk.
  • All values are integers.
  • The exact grid encoding follows the platform's expected return format.

Output Format

  • Return a grid satisfying the required number of paths.
  • If multiple grids are valid, any one is accepted.
  • If it is impossible, return the platform-specific empty output.

Constraints

  • Grid dimensions and kk are positive integers.
  • The exact limits are platform-specific and not provided here.
  • The construction should be efficient enough for interview settings.
Examples
Sample cases returned by the problem API.

Example 1

Input

m = 2, n = 2, k = 2

Output

[[1, 1], [1, 1]]

Explanation

This illustrative example shows a simple grid where the number of valid paths is exactly 2 under the usual right-and-down path model.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.