From 65946fc080ce7509052db7a2ea9bc0960c6d5b2d Mon Sep 17 00:00:00 2001 From: chayan das <110921638+Chayandas07@users.noreply.github.com> Date: Mon, 31 Mar 2025 22:33:08 +0530 Subject: [PATCH] Create 2551. Put Marbles in Bags --- 2551. Put Marbles in Bags | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 2551. Put Marbles in Bags diff --git a/2551. Put Marbles in Bags b/2551. Put Marbles in Bags new file mode 100644 index 0000000..890363e --- /dev/null +++ b/2551. Put Marbles in Bags @@ -0,0 +1,27 @@ +class Solution { +public: + long long putMarbles(vector& weights, int k) { + int n=weights.size(); + vector auxi; // create some Helping vector that store sum of pair. + + // Compute the sum of adjacent pairs + for(int i=0;i=n-k;i--){ + maxm= maxm+ auxi[i]; + } + return maxm-minm; + } +};