#3413

Maximum Coins From K Consecutive Bags

expert · 1170 · lc medium +32 · 24.5% accepted · 198 likes · top 3%

Description

Bags are placed at every integer coordinate on a number line. Some bags contain coins.

You are given a 2D array coins where coins[i] = [li, ri, ci] means every bag from position li to ri contains ci coins. The segments are non-overlapping.

You are also given an integer k.

Return the maximum number of coins collectible from any k consecutive bag positions.

Code

1
2
3