In this video, we solve Leetcode 2435. Paths in Matrix Whose Sum Is Divisible by K using Java.
Question Link - https://leetcode.com/problems/paths-in-matrix-whose-sum-is-divisible-by-k/description/?envType=daily-question&envId=2025-11-26
Solution: https://github.com/deepak-sharma-iOS/Leetcode-Daily-Challenge/blob/main/Leetcode-2435.java
Summary:
This solution uses DFS with memoization to count all paths from the top-left to bottom-right of the grid.
At each step, it tracks the running sum modulo **k** and only counts paths where the final remainder is zero.
The 3D dp cache (`dp[x][y][rem]`) avoids recomputation, storing results by position and current modulo remainder.
Subscribe - https://www.youtube.com/@DebugWithDeepak
Github - https://github.com/deepak-sharma-iOS/Leetcode-Daily-Challenge
Linkedin - https://www.linkedin.com/in/deepak-sharmaa-dev/
#CodeWithDeepak #LeetCodeDailyChallenge #LeetCodeSolutions #DSAforInterviews #CodingWithExplanation #TechInterviewPrep #CrackTheCodingInterview #DailyCodingChallenge #JavaCoding #LearnToCode #CodingShorts #leetcodedailychallenge #euclidean
Download
0 formats
No download links available.
Paths in Matrix Whose Sum Is Divisible by K | Leetcode 2435 | DSA | HIndi Explain | Code With Deepak | NatokHD