5

PROBLEM OF THE DAY : 10/02/2024 | Number of paths in a matrix with k coins

 7 months ago
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.
neoserver,ios ssh client

Number of paths in a matrix with k coins

February 14, 2024 |160 Views
PROBLEM OF THE DAY : 10/02/2024 | Number of paths in a matrix with k coins
Problem of the Day, Data Structures and Algorithms, graph
 Save  Share   Like
Description
Discussion

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

Read More

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK