NeetCode #823LC-2551HardGreedy
← Back to All Problems#823 · #2551 · Put Marbles in Bags(将珠子放入背包中)
📌 Problem Statement & Constraints
You are given an array
weights and an integer k. Split the array into k contiguous groups; the score of a group is the sum of its first and last weight, and the total score is the sum over groups. Return the difference between the maximum and minimum possible total score. Constraints: 2 <= k <= weights.length <= 10^5, 1 <= weights[i] <= 10^9.🔒
Sign In to Unlock Full Solutions for All 973 Problems
Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!