Number of Paths with Max Score
A hard-tier problem at 41% community acceptance, tagged with Array, Dynamic Programming, Matrix. Reported in interviews at Samsung and 0 others.
You're given a matrix where each cell has a score, and you need to find all paths from top-left to bottom-right that maximize the total score. This is a hard DP problem that looks straightforward until you realize you're solving two problems at once: finding the maximum score and counting how many paths achieve it. Samsung has asked this one. The trap is that most candidates write a standard max-path DP and forget they also need to track path count. If this hits your live OA cold, StealthCoder solves it invisibly while you're thinking through the approach.
Companies that ask "Number of Paths with Max Score"
Number of Paths with Max Score is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by a senior engineer who knows the OA is theater. This is the script.
Get StealthCoderThe core trick is running DP in two passes or one careful pass that tracks both the maximum score reachable from any cell AND the number of distinct paths that hit that maximum. Most people code the max-score part fine, then realize halfway through they have no way to count paths without recalculating. The gotcha: when you move right or down, you only increment path count if the new score equals the current best, not just any valid move. This is a Matrix and Array problem at its core, but the DP state design is where candidates stumble. You need to track dp[i][j] = (max_score, count_of_paths_at_max). If two directions lead to the same maximum, you add their counts. StealthCoder becomes your safety net if you blank on the dual-state design during the assessment.
Pattern tags
You know the problem.
Make sure you actually pass it.
Number of Paths with Max Score recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Number of Paths with Max Score interview FAQ
Is this really a hard problem or just tedious?+
It's hard because the dual-state DP (tracking max and count together) isn't obvious. The max-path part is textbook, but students forget they need to count paths only when they match the maximum, not on every valid move. That careless merge costs you.
What's the time and space complexity?+
Both O(m*n) where m and n are matrix dimensions. You iterate the grid once or twice and store one DP table. It's efficient, so the hard rating comes from the logic, not the complexity.
Do I need to reconstruct the actual paths or just count them?+
You only need the count of maximum-score paths, not the paths themselves. That's what saves this from being even harder. If you had to return the paths, it'd be exponential space.
How does this relate to classic DP problems?+
It's a hybrid of 'maximum path sum' and 'unique paths'. Both are common, but combining them into one state machine is what makes this hard. You can't solve them separately and merge results.
Samsung is the only company listed. Is this still relevant?+
One confirmed report doesn't mean others don't ask it. Hard matrix DP problems appear across many companies. The low acceptance rate (41%) suggests it's still filtering candidates effectively at every tier.
Want the actual problem statement? View "Number of Paths with Max Score" on LeetCode →