PROBLEM OF THE DAY : 10/02/2024 | Number of paths in a matrix with k coins
source link: https://www.geeksforgeeks.org/videos/problem-of-the-day-10022024-number-of-paths-in-a-matrix-with-k-coins/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Number of paths in a matrix with k coins
Welcome to the daily solving of our PROBLEM OF THE DAY with Siddharth Hazra. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Graph but also build up problem-solving skills.
In this problem, we are given a n x n matrix such that each of its cells contains some coins. Count the number of ways to collect exactly k coins while moving from the top left corner of the matrix to the bottom right. From a cell (i, j), you can only move to (i+1, j) or (i, j+1).
Example :
Input:
k = 12, n = 3
arr[] = [[1, 2, 3],
[4, 6, 5],
[3, 2, 1]]
Output:
2
Explanation:
There are 2 possible paths with exactly 12 coins, (1 + 2 + 6 + 2 + 1) and (1 + 2 + 3 + 5 + 1).
Give the problem a try before going through the video. All the best!!!
Problem Link: https://www.geeksforgeeks.org/problems/number-of-paths-in-a-matrix-with-k-coins2728/1
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK