[LeetCode] Maximum Sum With at Most K Elements

1 · · Feb. 23, 2025, 4:21 a.m.
Summary
3462. Maximum Sum With at Most K Elements You are given a 2D integer matrix grid of size n x m, an integer array limits of length n, and an integer k. The task is to find the maximum sum of at most k elements from the matrix grid such that: The number of elements taken from the ith row of grid does not exceed limits[i]. Return the maximum sum. ...