Tap here to switch tabs
Problem
Submissions

Problem: Find the Kth Smallest Sum of a Matrix With Sorted Rows

med
30 min
Try to solve the Find the Kth Smallest Sum of a Matrix With Sorted Rows problem.

Statement

You are given an mimesnm imes n matrix mat where each row is sorted in nondecreasing order, and an integer k.

You can select exactly one element from each row to form a combination. The sum of a combination is the total of its chosen elements.

Return the kextthk^{ ext{th}} smallest combination sum among all possible choices.

Constraints:

  • m == mat.length

  • n == mat[i].length

  • 1≤1 \leq m, n ≤40\leq 40

  • 1≤1 \leq mat[i][j] ≤5000\leq 5000

  • 1≤1 \leq k ≤min⁡(200,nm)\leq \min(200, n^m)

  • mat[i] is sorted in nondecreasing order.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Kth Smallest Sum of a Matrix With Sorted Rows

med
30 min
Try to solve the Find the Kth Smallest Sum of a Matrix With Sorted Rows problem.

Statement

You are given an mimesnm imes n matrix mat where each row is sorted in nondecreasing order, and an integer k.

You can select exactly one element from each row to form a combination. The sum of a combination is the total of its chosen elements.

Return the kextthk^{ ext{th}} smallest combination sum among all possible choices.

Constraints:

  • m == mat.length

  • n == mat[i].length

  • 1≤1 \leq m, n ≤40\leq 40

  • 1≤1 \leq mat[i][j] ≤5000\leq 5000

  • 1≤1 \leq k ≤min⁡(200,nm)\leq \min(200, n^m)

  • mat[i] is sorted in nondecreasing order.