Skip to main content

TCS

TCS OA-27 2024

Problem Description

You are given a robot positioned at the top-left corner of an m×n grid, represented by coordinates (0,0). The robot aims to reach the bottom-right corner of the grid, located at (m−1,n−1). The robot can only move in two directions at any given point:

  • Right (to the cell directly to the right)
  • Down (to the cell directly below)

Your task is to calculate the number of unique paths the robot can take to reach the bottom-right corner.

Input Format

Two integers, m and n, where m is the number of rows and n is the number of columns in the grid.

Output Format

An integer representing the total number of unique paths from the top-left corner to the bottom-right corner.

Constraints

  • 1≤ m,n ≤100
  • The answer will be less than or equal to 2 * 109

Example

Sample Input:

3 7

Sample Output:

28

Explanation:

The robot can take 28 unique paths from (0,0) to (2,6).