

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Count all possible paths from top left to bottom right of a mXn matrix in C++
<p>In this tutorial, we will be discussing a program to find the number of possible paths from top left to bottom right of a mXn matrix.</p><p>For this we will be provided with a mXn matrix. Our task is to find all the possible paths from top left to bottom right of the given matrix.</p><h2>Example</h2><pre class="prettyprint notranslate">#include <iostream> using namespace std; //returning count of possible paths int count_paths(int m, int n){ if (m == 1 || n == 1) return 1; return count_paths(m - 1, n) + count_paths(m, n - 1); } int main(){ cout << count_paths(3, 3); return 0; }</pre><h2>Output</h2><pre class="result notranslate">6</pre>
- Related Questions & Answers
- Print all possible paths from top left to bottom right of a mXn matrix in C++
- Print all palindromic paths from top left to bottom right in a matrix in C++
- Print all paths from top left to bottom right in a matrix with four moves allowed in C++
- Maximum points from top left of matrix to bottom right and return back in C++
- Program to count number of walls required to partition top-left and bottom-right cells in Python
- Set the left, right, top and bottom padding of an element
- How to display the JList items from top to bottom and left to right in Java?
- Count all possible paths between two vertices in C++
- Program to find number of ways we can reach from top left point to bottom right point in Python
- How to add a straight line to a plot in R starting from bottom left and ending at top right?
- Maximum sum path in a matrix from top to bottom in C++
- Print a matrix in alternate manner (left to right then right to left) in C++
- Maximum sum path in a matrix from top to bottom in C++ Program
- Print all leaf nodes of a binary tree from right to left in C++
- Maximum sum path in a matrix from top to bottom and back in C++ Program
Advertisements