Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8990177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:26:36+00:00 2026-06-15T22:26:36+00:00

A p x q size matrix is given, and a matrix of size a

  • 0

A p x q size matrix is given, and a matrix of size a x b is removed from top right corner. Find the total no. of paths from top left to bottom right, with only right and down movements allowed. No path should go into the removed matrix.

eg-

 _
|_|_
|_|_|

this is (2x2) matrix after removing (1x1) matrix from top right corner. no. of ways – 5.

I am able to find out the total number of paths, but the method I am thinking of eliminating the paths that go into the removed portion is very elementary and hence not efficient.

So, are there any better algorithm for it ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:26:38+00:00Added an answer on June 15, 2026 at 10:26 pm

    You can exploit the structure of the grid:

    The number of paths from one corner to the other on a square grid is given by the size of the grid by the pascal’s triangle: (x+y) choose x

    Each path must cross exactly one point on each diagonal.

    Take all points on the diagonal that passes through the inner corner, calculate the number of paths through each, and sum.

    This leads to an O(min(p-a, q-b)) algorithm assuming constant-time arithmetic.

    In your case: (two paths to the center) * (two paths from the center) + (one path through the corner) = (four paths through the center) + (one path through the corner) = (five paths)

    +-+-+
    | | |
    +-+-A-+-+
    | | | | |
    +-B-+-+-+
    | | | | |
    C-+-+-+-+
    | | | | |
    +-+-+-+-+
    
      (1+2) choose 1 * (2+3) choose 2 (through A)
    + (2+1) choose 2 * (3+2) choose 3 (through B)
    + (3+0) choose 3 * (4+1) choose 4 (through C)
    
    = 3 choose 1 * 5 choose 2
    + 3 choose 2 * 5 choose 3
    + 3 choose 3 * 5 choose 4
    
    = 3*10
    + 3*10
    + 1*5
    
    = 30+30+5 = 65 paths
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a matrix of size mxn containing 0's and 1's only. I need to
This is an interview question: given a boolean matrix find the size of the
Given a binary matrix M of size n x k , i would like
Given an NxN binary matrix (containing only 0's or 1's), how can we go
I have a matrix M containing pairs (i.e. arrays of size 2). Given a
I've a large D Matrix of size MxNxK. Given a binary mask B of
Given a matrix of size n x m filled with 0's and 1's e.g.:
Given the size of an matrix and a position p. How do I fill
Given a binary matrix A of size n x k , i would like
Given a matrix of size M and N , we want to fill in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.