Maximizing Array Sum After K Negations, Gas Station Problem, and Candy Distribution
Maximizing Array Sum After K Negations
Given an integer array, we can perform K operations where each operation flips the sign of an element. The goal is to maximize the sum after exactly K operations.
Approach:
Sort the array by absolute values in descending order
Flip negative numbers first too maximize sum gains
If remaining operations are ...
Posted on Wed, 26 Aug 2026 16:26:56 +0000 by A3aan
Memoization Recursion and Dynamic Programming: Solving Optimization Problems Efficiently
Guess Number Higher or Lower II
We need to solve a game where we guess a number between 1 and n. Each wrong guess costs the amount equal to the guessed number. The goal is to find the minimum amount of money needed to guarantee a win regardless of which number is selected.
Brute-Force Recursion
class Solution {
public:
int calculateMinCost( ...
Posted on Wed, 15 Jul 2026 17:20:52 +0000 by djBuilder