2026 February 28 Problems

51 views
Skip to first unread message

daryl...@gmail.com

unread,
Feb 28, 2026, 12:41:32 PM (11 days ago) Feb 28
to leetcode-meetup
Feel free to work on any of the problems you want; we'll have people present their solutions at 11:30.

Please post your solutions to this thread so others can use this as a reference.


3788. Maximum Score of a Split Medium 51.5%

3826. Minimum Partition Score Hard 33.9%


We're going to use the same Google meet link as the last few times: https://meet.google.com/xnn-kifj-jnx?pli=1

Anuj Patnaik

unread,
Feb 28, 2026, 12:50:15 PM (11 days ago) Feb 28
to leetcode-meetup
class Solution:
def countPartitions(self, nums: List[int]) -> int:
prefix_sum = [0] * len(nums)
prefix_sum[0] = nums[0]
prefix_sum[1] = nums[1] + nums[0]
ct = 0
for i in range(2, len(nums)):
prefix_sum[i] = prefix_sum[i-1] + nums[i]
for j in range(len(nums) - 1):
if (2*nums[j] - prefix_sum[len(nums) - 1]) % 2 == 0:
ct += 1
return ct

Allen S.

unread,
Feb 28, 2026, 1:02:09 PM (11 days ago) Feb 28
to leetcode-meetup
func countPartitions(nums []int) int {
totalSum := 0
for _, v := range nums {
totalSum += v
}
if totalSum % 2 == 0 {
return len(nums) - 1
}
return 0
}

Anuj Patnaik

unread,
Feb 28, 2026, 1:04:03 PM (11 days ago) Feb 28
to leetcode-meetup
class Solution:
def maximumScore(self, nums: List[int]) -> int:
prefix_sum = [0] * len(nums)
prefix_sum[0] = nums[0]
prefix_sum[1] = nums[1] + nums[0]
ct = 0
for i in range(2, len(nums)):
prefix_sum[i] = prefix_sum[i-1] + nums[i]
suffix_min = [0] * len(nums)
suffix_min[len(nums) -1] = nums[len(nums) - 1]
for j in range(len(nums) - 2, -1, -1):
suffix_min[j] = min(nums[j], suffix_min[j+1])
max_score = float('-inf')
for k in range(len(nums) - 1):
max_score = max(max_score, prefix_sum[k] - suffix_min[k+1])
return max_score

Allen S.

unread,
Feb 28, 2026, 1:27:21 PM (10 days ago) Feb 28
to leetcode-meetup
func maximumScore(nums []int) int64 {
prefSum := make([]int, len(nums))
curSum := 0
for i, v := range nums {
curSum += v
prefSum[i] = curSum
}

var res int64 = math.MinInt64
sufMin := nums[len(nums)-1]
for i := len(nums) - 2; i >= 0; i-- {
score := int64(prefSum[i]) - int64(sufMin)
res = max(res, score)
sufMin = min(sufMin, nums[i])
}
return res
}

Bhupathi Kakarlapudi

unread,
Feb 28, 2026, 1:59:54 PM (10 days ago) Feb 28
to leetcod...@googlegroups.com
class Solution:
def countPartitions(self, nums: List[int]) -> int:
count:int = 0
s:int = 0

nums_len = len(nums)

# prefix sum
psum = [s:=s+n for n in nums ]

for i in range(nums_len - 1):
diff:int = abs(psum[i] - (psum[nums_len-1] - psum[i]))
if diff % 2 == 0:
count += 1

return count

--
whatspp group: http://whatsapp.techbayarea.us/
---
You received this message because you are subscribed to the Google Groups "leetcode-meetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leetcode-meet...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/leetcode-meetup/a803ad3e-e6ae-433b-8f30-af15ce6b0335n%40googlegroups.com.

Vivek Hajela

unread,
Feb 28, 2026, 2:04:02 PM (10 days ago) Feb 28
to leetcod...@googlegroups.com

***********************************************************************************
3788. Maximum Score of a Split Medium 51.5%
*********************************************************************************

Time complexity = O(n+k)
Space complexity = O(n)

class Solution {
public:
    struct comp {
        bool operator()(const pair<int, int>& p1,
                        const pair<int, int>& p2) const {
            if (p1.first == p2.first) {
                return p1.second > p2.second;
            }
            return p1.first > p2.first;
        }
    };
    long long maximumScore(vector<int>& nums) {

        vector<long long> prefixSum;
        long long runningSum = 0;

        priority_queue<pair<int, int>, vector<pair<int, int>>, comp> PQ;
        for (int i = 0; i < nums.size(); i++) {
            if (i > 0) {
                PQ.push(make_pair(nums[i], i));
            }
            if (i < nums.size() - 1) {
                runningSum += nums[i];
                prefixSum.push_back(runningSum);
            }
        }

        long long maximumScore = LONG_LONG_MIN;

        for (int i = 0; i < nums.size() - 1; i++) {

            while (!PQ.empty() && i >= PQ.top().second)
                PQ.pop();

            if (!PQ.empty()) {
                long long pSum = prefixSum[i] - PQ.top().first;
                maximumScore = max(maximumScore, pSum);
            }
        }
        return maximumScore;
    }
};

--
whatspp group: http://whatsapp.techbayarea.us/
---
You received this message because you are subscribed to the Google Groups "leetcode-meetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leetcode-meet...@googlegroups.com.

Carlos Green

unread,
Feb 28, 2026, 2:15:26 PM (10 days ago) Feb 28
to leetcode-meetup

var RecentCounter = function() {
this.counter = []
};

/**
* @param {number} t
* @return {number}
*/
RecentCounter.prototype.ping = function(t) {
this.counter.push(t)
let count = 0

for (let c of this.counter) {
if (c + 3000 >= t) {
count++
}
}
return count
};

/**
* Your RecentCounter object will be instantiated and called as such:
* var obj = new RecentCounter()
* var param_1 = obj.ping(t)
*/

Bhupathi Kakarlapudi

unread,
Feb 28, 2026, 2:36:30 PM (10 days ago) Feb 28
to leetcod...@googlegroups.com
class Solution:
def maximumScore(self, nums: List[int]) -> int:
max_score:int = None
s:int = 0
nums_len:int = len(nums)
sufix_min:list = []
score:int = None


# prefix sum
psum = [s:=s+n for n in nums ]

for i in range(nums_len - 1):
sufix_min.append(min(nums[i+1:]))

for i in range(nums_len - 1):
score = psum[i] - sufix_min[i]

if max_score == None:
max_score = score

if score > max_score:
max_score = score


return max_score

Carlos Green

unread,
Feb 28, 2026, 2:44:01 PM (10 days ago) Feb 28
to leetcode-meetup
Haha, I did the wrong question for this week

/**
* @param {number[]} nums
* @return {number}

Time & Space O(n)
*/
var countPartitions = function(nums) {
let count = 0


for (let i = 1; i < nums.length; i++) {
const left = nums.slice(0, i).reduce((a,c) => a += c, 0)
const right = nums.slice(i, nums.length).reduce((a,c) => a += c, 0)

if ((left - right) % 2 === 0) {
count++
}
}


return count
};
Reply all
Reply to author
Forward
0 new messages